puppetlabs / puppetlabs/puppetlabs-bash_task_helper
Fails when `set -u` is used
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1
- Forks
- 11
- Avg merge
- 10h 40m
- Merged PRs (30d)
- 5
Description
Describe the Bug
When the bash setting -u is set to fail on usage of undefined variables, the task helper exits after execution.
Expected Behavior
That it doesn't.
Steps to Reproduce
- Create a task.
- Use
set -euo pipefail.
Environment
- Version: 2.0.0
- Platform: Debian 12
Additional Context
The error doesn't happen when using e.g. set -eo pipefail.
While testing, I noticed that it does not happen when the there is at least one task-output command between the source call and set -euo pipefail, that is:
source bash_task_helper/files/task_helper.sh
echo foo
set -euo pipefail
task-succeed baz
does not work, but
source bash_task_helper/files/task_helper.sh
task-output foo bar
set -euo pipefail
task-succeed baz
works:
{
"foo": "bar",
"status": "success",
"_output": "baz"
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with bash_task_helper/files/task_helper.sh and reproduce the issue using a task with set -euo pipefail, comparing the failing case with one containing task-output between sourcing and the setting. Done means the task helper no longer exits unexpectedly when set -u is enabled, while the existing task-output behavior remains valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100