-
Notifications
You must be signed in to change notification settings - Fork 455
fix: pre-4.4 bash workaround for empty arrays with 'set -u'. #550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: pre-4.4 bash workaround for empty arrays with 'set -u'. #550
Conversation
martin-schulze-vireso
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I am suprised that this slipped through, as there are tests in place for exactly this scenario. Can you provide a reproducer?
0586445 to
7499b20
Compare
7499b20 to
2330a44
Compare
|
I replace your commit with the additional tests with a fix for the existing tests. We already have a full parallelization test that relies on passing BATS_NUMBER_OF_PARALLEL_JOBS but the test erased that from the environment and the internal handling of this env var was broken when it was empty but defined. |
Add a workaround (akin to ff630de) to prevent pre-4.4 bash versions throwing an unbound variable error for empty arrays when dereferenced using '{[@]}'. This bash behavior/bug manifests itself when tests are run with 'set -u' as error like this: /usr/libexec/bats-core/bats-exec-file: line 225: flags[@]: unbound variable Signed-off-by: Krisztian Litkey <[email protected]>
2330a44 to
e52a152
Compare
Thanks ! And sorry for not spotting that possibility myself. I'm just lacking way too much context/familiarity with BATS for that to have happened. |
Don't worry, I did not expect you to. After all, I did not spot the problem myself. It seems my fix uncovered another problem with aborting tests in parallel mode. As I am quite late in the release schedule, I might defer that issue but I plan to get this PR in. |
Add a workaround (akin to ff630de) to prevent pre-4.4 bash versions
throwing an unbound variable error for empty arrays when dereferenced
using '{[@]}'. This bash behavior/bug manifests itself when tests are
run with 'set -u' as error like this:
/usr/libexec/bats-core/bats-exec-file: line 225: flags[@]: unbound variable
This happens on CentOS-7 (
GNU bash, version 4.2.46(2)-release (x86_64-unknown-linux-gnu))with all versions of bats.