diff --git a/SC2244.md b/SC2244.md index adc589c..5c0d444 100644 --- a/SC2244.md +++ b/SC2244.md @@ -31,15 +31,20 @@ fi ### Rationale: -`[ "$var" ]` is equivalent to `[ -n "$var" ]` and checks whether the string is non-empty. +`[ "$var" ]` is equivalent to `[ -n "$var" ]` and checks that a string is non-empty. -Users more familiar with other languages are therefore often surprised to learn that `[ "$var" ]` is true when `var=false` or `var=0`. +Users more familiar with other languages are often surprised to learn that `[ "$var" ]` is true when: -Adding the explicit `-n` helps clarify that this is a string comparison, and not related to any concept of boolean values or comparisons as it is in most languages. +* `var=false` +* `var=0` +* `var=null` +* `var=" "` + +Adding the explicit `-n` helps clarify that this is a string comparison, and not related to any concept of boolean values or "truthiness" as it is in most languages. ### Exceptions: -If you are familiar with the semantics of `[`, you can [[ignore]] this suggestion with no ill effects. +If you are familiar with the semantics of `[`, you can [[ignore]] this stylistic suggestion with no ill effects. ### Related resources: