SHARE
TWEET

Untitled

a guest Apr 18th, 2019 107 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string1 has not been initialized, it has no defined value
  2.  
  3. 1. Non-quote string in test brackets. Wrong results !
  4. > [ -n $string1 ] &&  echo "String1 is not null"
  5. -> Show "String1 is not null" --> Wrong results.
  6. 2. Quote string within test brackets.
  7. > [ -n "$string1"] && echo "String1 is not null"
  8. ->    --> This works fines
  9. 3. string1 stands naked. Must quoting. See the following examples
  10.     3.1 Unquoted
  11. > [ $string1 ] && echo "String1 is not null"
  12. ->   --> This works fine.
  13. > string1="a = b"
  14. > [ $string1 ] && echo "String1 is not null"
  15. ->   --> Wrong result !
  16.     3.2 Quoted
  17. > string1="a = b"
  18. > [ "$string1" ] && echo "String1 is not null"
  19. -> Show "String1 is not null"  --> This works fine
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top