mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC2237 (markdown)
@@ -20,6 +20,7 @@ if [ -n "$STY" ]; then echo "You are already running screen"; fi
|
|||||||
|
|
||||||
You have negated `test -z` or `test -n`, resulting in a needless double-negative. You can just use the other operator instead:
|
You have negated `test -z` or `test -n`, resulting in a needless double-negative. You can just use the other operator instead:
|
||||||
|
|
||||||
|
```sh
|
||||||
# Identical tests to verify that a value is assigned
|
# Identical tests to verify that a value is assigned
|
||||||
! [ -z foo ] # Not has no value
|
! [ -z foo ] # Not has no value
|
||||||
[ -n foo ] # Has value
|
[ -n foo ] # Has value
|
||||||
@@ -27,6 +28,7 @@ You have negated `test -z` or `test -n`, resulting in a needless double-negative
|
|||||||
# Identical tests to verify that a value is empty
|
# Identical tests to verify that a value is empty
|
||||||
! [ -n foo ] # Not is non-empty
|
! [ -n foo ] # Not is non-empty
|
||||||
[ -z foo ] # Is empty
|
[ -z foo ] # Is empty
|
||||||
|
```
|
||||||
|
|
||||||
### Exceptions:
|
### Exceptions:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user