Timeline for Test for non-zero length string in Bash: [ -n "$var" ] or [ "$var" ]
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 23, 2019 at 12:04 | history | edited | Peter Mortensen | CC BY-SA 4.0 |
Expanded.
|
Aug 15, 2018 at 17:40 | comment | added | Charles Duffy |
...which is to say, don't use -a or -o to combine tests but instead use [ ... ] && [ ... ] or [ ... ] || [ ... ] and the only corner cases that can apply to using arbitrary variables' data in a test are unambiguously closed.
|
|
Aug 15, 2018 at 17:37 | comment | added | Charles Duffy |
You don't even need this with pre-bash shells, if you're avoiding syntax that the POSIX standard explicitly marks obsolescent. [ "$ENV_VARIABLE" != "" ] will work on every shell with a POSIX-compliant test implementation -- not just bash, but ash/dash/ksh/etc.
|
|
Jul 26, 2016 at 22:00 | comment | added | tbc0 |
This is very old-school from the Bourne shell days. Don't perpetuate this old habit. bash is a sharper tool than its predecessors.
|
|
Apr 6, 2016 at 10:22 | history | edited | user1310789 | CC BY-SA 3.0 |
deleted 320 characters in body
|
Apr 6, 2016 at 10:13 | review | Late answers | |||
Apr 6, 2016 at 10:14 | |||||
Apr 6, 2016 at 9:58 | history | answered | user1310789 | CC BY-SA 3.0 |