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

Add note about whitespace when introducing [ ] and [[ ]] #40

Open
sumbach opened this issue Jan 31, 2016 · 0 comments
Open

Add note about whitespace when introducing [ ] and [[ ]] #40

sumbach opened this issue Jan 31, 2016 · 0 comments
Labels

Comments

@sumbach
Copy link
Collaborator

sumbach commented Jan 31, 2016

I think it would be valuable to explicitly talk about whitespace requirements in [ ] and [[ ]] conditionals--this tripped me up when learning Bash and I know it's a pain point for a lot of developers.

The way I like to think about it is that [ and [[ are commands/builtins (like echo, etc), as opposed to being part of Bash syntax. For this reason, the command name and each of its arguments must be separated by whitespace:

[[ -n "$1" ]]

# not
[[-n"$1"]]
[[-n "$1"]]
[[ -n"$1" ]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants