diff options
author | ven <vendethiel@hotmail.fr> | 2016-01-13 14:58:18 +0100 |
---|---|---|
committer | ven <vendethiel@hotmail.fr> | 2016-01-13 14:58:18 +0100 |
commit | e16ad03d4a0209cb88d3e4042252c42c6e977370 (patch) | |
tree | ddcada013ce00b8e7c7a2894ffd847e55aabf58f | |
parent | 7e069bef5d094169c24b7ee5cdd4757eb51e1da3 (diff) | |
parent | f94dea8379b5e7a28990eac371f9c9cca19ab472 (diff) |
Merge pull request #2097 from matteobaglini/master
[bash/en] fix comparison syntax
-rw-r--r-- | bash.html.markdown | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/bash.html.markdown b/bash.html.markdown index 211d2944..bd2d5984 100644 --- a/bash.html.markdown +++ b/bash.html.markdown @@ -83,7 +83,7 @@ echo Hello, $Name! # We have the usual if structure: # use 'man test' for more info about conditionals -if [ $Name -ne $USER ] +if [ $Name != $USER ] then echo "Your name isn't your username" else @@ -91,12 +91,12 @@ else fi # NOTE: if $Name is empty, bash sees the above condition as: -if [ -ne $USER ] +if [ != $USER ] # which is invalid syntax # so the "safe" way to use potentially empty variables in bash is: -if [ "$Name" -ne $USER ] ... +if [ "$Name" != $USER ] ... # which, when $Name is empty, is seen by bash as: -if [ "" -ne $USER ] ... +if [ "" != $USER ] ... # which works as expected # There is also conditional execution |