mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC2193 (markdown)
14
SC2193.md
14
SC2193.md
@@ -3,17 +3,19 @@
|
||||
### Problematic code:
|
||||
|
||||
```sh
|
||||
[[ "{$var}" == "value" ]] # Swapped around $ and {
|
||||
[[ "$(cmd1) | cmd2" == "42" ]] # Ended with ) too soon
|
||||
[[ "$var " == *.png ]] # Trailing space
|
||||
[ $var+1 == 5 ] # Unevaluated math
|
||||
[ "{$var}" == "value" ] # Swapped around $ and {
|
||||
[ "$(cmd1) | cmd2" == "42" ] # Ended with ) too soon
|
||||
[[ "$var " == *.png ]] # Trailing space
|
||||
```
|
||||
|
||||
### Correct code:
|
||||
|
||||
```sh
|
||||
[[ "${var}" == "value" ]] # Correct variable expansion
|
||||
[[ "$(cmd1 | cmd2)" == "42" ]] # Correct command substitution
|
||||
[[ "$var" == *.png ]] # No trailing space
|
||||
[ $((var+1)) == 5 ] # Evaluated math
|
||||
[ "${var}" == "value" ] # Correct variable expansion
|
||||
[ "$(cmd1 | cmd2)" == "42" ] # Correct command substitution
|
||||
[[ "$var" == *.png ]] # No trailing space
|
||||
```
|
||||
### Rationale:
|
||||
|
||||
|
Reference in New Issue
Block a user