Or when you use if [ -n "string"]; then ... in shell.
> test -n string
returns 1 if string is not empty and 0 otherwise.
> test -n
returns 1
> test -n ""
returns 0
This brings up an important point, you need to quote the string in shell otherwise 'test' will think there is no argument for empty string and returns 1 (wrong result).
if [ -n "$my_string" ]; then
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment