Skip to content

Use [ instead of bash-specific [[ for test #34

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

Merged
merged 2 commits into from
Dec 6, 2018
Merged

Use [ instead of bash-specific [[ for test #34

merged 2 commits into from
Dec 6, 2018

Conversation

edwinbalani
Copy link
Contributor

@edwinbalani edwinbalani commented Aug 28, 2017

The '[[' test is a bash-specific builtin, so on systems where #!/usr/bin/env sh (the hashbang line) doesn't return a bash executable, you can get this error:

/usr/bin/git-fire: 52: /usr/bin/git-fire: [[: not found

In my case the script was running in dash, which doesn't have the builtin and aims for POSIX compliance over additional features.

The commit changes the test on line 52 to use the [ executable instead, and adds quotes around the $( ) expression for escaping.

@dyc3
Copy link

dyc3 commented Sep 22, 2017

Why not change the shebang to #!/usr/bin/env bash then?

@edwinbalani
Copy link
Contributor Author

Why not change the shebang to #!/usr/bin/env bash then?

Because that would make the script dependent on having bash installed. In 95% of cases that's probably a safe bet, but there will always be edge cases ;). Having a POSIX-compliant shell available at sh is essentially mandatory, though, so can be relied upon.

Also, [ was already being used in the script (see here) before the block containing the [[ was merged in #27.

@qw3rtman qw3rtman merged commit f2040e0 into qw3rtman:master Dec 6, 2018
@qw3rtman
Copy link
Owner

qw3rtman commented Dec 6, 2018

@edwinbalani, thank you for your contribution and comments. Portability (i.e: POSIX-compliance) is crucial.

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.

3 participants