Skip to content
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

Check Bash version #873

Merged

Conversation

akinomyoga
Copy link
Contributor

I here suggest including the check for the Bash version at the beginning of bats.

Using Bats, I would like to test if Bash frameworks would correctly work in different versions of Bash. I tried to run the test for the devel version of Bash, the latest release 5.2, down to Bash 3.0. However, the test fails because of syntax errors for Bash 3.0 and 3.1. It turned out that the failure is not caused by the Bash frameworks that are tested but by the bats test framework itself. I'd like to request Bats to check the Bash version first and output an error message if the minimum Bash version requirement by Bats is not satisfied.

I tried to find an explicit notice about the required Bash version, but I couldn't find any information. What is the minimum Bash version supported by Bats? I here assume it is 3.2 because Bats produce syntax errors in Bash 3.0 and 3.1, while some files seem to contain checks for 3.2 (e.g. in test/trace.bats).

  • I have reviewed the Contributor Guidelines.
    • The guideline says [[ ... ]] should be always used, but can I use [ ... ] for the very initial test for the shell? Relying on the Bash feature for the test of whether the Bash feature is available doesn't seem to make sense.
    • Also, the guideline says "Always use [[ and ]] for evaluating variables", but what "evaluating variables" means is unclear. I assume it considers just the two variations of [[ ... ]] and [ ... ]. However, technically, it might also exclude the uses of the arithmetic commands of the form (( ... )). I used the arithmetic command in this PR because arithmetic commands seem to be already used in the codebase.
  • I have reviewed the Code of Conduct and agree to abide by it
    • Unrelated to this PR, but the "Current Maintainers" section seems outdated.

bin/bats Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
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.

Please add the changelog entry

@akinomyoga
Copy link
Contributor Author

Thank you for your review. I updated and rebased it on top of the latest master, and all the CI tests seem to have passed.

@martin-schulze-vireso martin-schulze-vireso merged commit ab2a86e into bats-core:master Mar 1, 2024
14 checks passed
@martin-schulze-vireso
Copy link
Member

Thanks for your contribution. I slightly reworded the changelog entry and signed the commit.

@akinomyoga akinomyoga deleted the check-bash-version branch March 1, 2024 23:50
@akinomyoga
Copy link
Contributor Author

Thank you!

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.

None yet

2 participants