mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 11:19:45 +08:00
Add example for testing equality
20
SC2039.md
20
SC2039.md
@@ -23,6 +23,26 @@ a="$(printf '%b_' ' \t\n')"; a="${a%_}" # protect trailing \n
|
||||
|
||||
Want some good news? See http://austingroupbugs.net/view.php?id=249#c590.
|
||||
|
||||
### Testing Equality
|
||||
|
||||
`==` operator is not supported in POSIX `sh`
|
||||
|
||||
Bash:
|
||||
|
||||
```Bash
|
||||
if [ "$a" == "$b" ]; then
|
||||
echo "equal"
|
||||
fi
|
||||
```
|
||||
|
||||
POSIX:
|
||||
|
||||
```sh
|
||||
if [ "$a" -eq "$b" ]; then
|
||||
echo "equal"
|
||||
fi
|
||||
```
|
||||
|
||||
### `$"msgid"`
|
||||
|
||||
Bash:
|
||||
|
Reference in New Issue
Block a user