Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string1 has not been initialized, it has no defined value
- 1. Non-quote string in test brackets. Wrong results !
- > [ -n $string1 ] && echo "String1 is not null"
- -> Show "String1 is not null" --> Wrong results.
- 2. Quote string within test brackets.
- > [ -n "$string1"] && echo "String1 is not null"
- -> --> This works fines
- 3. string1 stands naked. Must quoting. See the following examples
- 3.1 Unquoted
- > [ $string1 ] && echo "String1 is not null"
- -> --> This works fine.
- > string1="a = b"
- > [ $string1 ] && echo "String1 is not null"
- -> --> Wrong result !
- 3.2 Quoted
- > string1="a = b"
- > [ "$string1" ] && echo "String1 is not null"
- -> Show "String1 is not null" --> This works fine
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement