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

SC2292 description reads as though [[ ]] are a drop in replacement for [ ] in Bash #3162

Open
qha opened this issue Mar 19, 2025 · 1 comment

Comments

@qha
Copy link

qha commented Mar 19, 2025

This is not the case however.

One issue i ran in to is that they treat leading zeroes differently:

% bash --norc
bash-5.2$ [ 0700 -lt 643 ]; echo $?
1
bash-5.2$ [[ 0700 -lt 643 ]]; echo $?
0

Another issue is that "equality" gives different results depending on your quoting:

% bash --norc
bash-5.2$ [ xyzzy = xy*y ]; echo $?
1
bash-5.2$ [[ xyzzy = xy*y ]]; echo $?
0
bash-5.2$ [ "xyzzy" = "xy*y" ]; echo $?
1
bash-5.2$ [[ "xyzzy" = "xy*y" ]]; echo $?
1

I'm not sure if this is just a documentation issue or if some further checks could be written.

@qha
Copy link
Author

qha commented Mar 19, 2025

(The second issue is alluded to in the Bash faq resource if you read it very carefully.)

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

No branches or pull requests

1 participant