puppetlabs / puppetlabs/puppetlabs-bash_task_helper

Fails when `set -u` is used

Open
#31 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

  1. Create a task.
  2. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.