mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 11:19:45 +08:00
Updated SC2237 (markdown)
14
SC2237.md
14
SC2237.md
@@ -20,13 +20,15 @@ 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:
|
||||
|
||||
# Identical tests to verify that a value is assigned
|
||||
! [ -z foo ] # Not has no value
|
||||
[ -n foo ] # Has value
|
||||
```sh
|
||||
# Identical tests to verify that a value is assigned
|
||||
! [ -z foo ] # Not has no value
|
||||
[ -n foo ] # Has value
|
||||
|
||||
# Identical tests to verify that a value is empty
|
||||
! [ -n foo ] # Not is non-empty
|
||||
[ -z foo ] # Is empty
|
||||
# Identical tests to verify that a value is empty
|
||||
! [ -n foo ] # Not is non-empty
|
||||
[ -z foo ] # Is empty
|
||||
```
|
||||
|
||||
### Exceptions:
|
||||
|
||||
|
Reference in New Issue
Block a user