Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@klihub
Copy link
Contributor

@klihub klihub commented Feb 21, 2022

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.

  • I have reviewed the [Contributor Guidelines][contributor].
  • I have reviewed the [Code of Conduct][coc] and agree to abide by it

Copy link
Member

@martin-schulze-vireso martin-schulze-vireso left a 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?

@klihub klihub force-pushed the fixes/bash-pre-4.4/unbound-flags branch 2 times, most recently from 0586445 to 7499b20 Compare February 21, 2022 18:04
martin-schulze-vireso added a commit to martin-schulze-vireso/bats-core that referenced this pull request Feb 22, 2022
martin-schulze-vireso added a commit to martin-schulze-vireso/bats-core that referenced this pull request Feb 22, 2022
@martin-schulze-vireso martin-schulze-vireso force-pushed the fixes/bash-pre-4.4/unbound-flags branch from 7499b20 to 2330a44 Compare February 22, 2022 14:29
@martin-schulze-vireso
Copy link
Member

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.

klihub and others added 3 commits February 23, 2022 13:49
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]>
@klihub klihub force-pushed the fixes/bash-pre-4.4/unbound-flags branch from 2330a44 to e52a152 Compare February 23, 2022 11:49
@klihub
Copy link
Contributor Author

klihub commented Feb 23, 2022

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.

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.

@martin-schulze-vireso
Copy link
Member

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.

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.

@martin-schulze-vireso martin-schulze-vireso merged commit 13d7bcb into bats-core:master Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants