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:
|
### Problematic code:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
[[ "{$var}" == "value" ]] # Swapped around $ and {
|
[ $var+1 == 5 ] # Unevaluated math
|
||||||
[[ "$(cmd1) | cmd2" == "42" ]] # Ended with ) too soon
|
[ "{$var}" == "value" ] # Swapped around $ and {
|
||||||
[[ "$var " == *.png ]] # Trailing space
|
[ "$(cmd1) | cmd2" == "42" ] # Ended with ) too soon
|
||||||
|
[[ "$var " == *.png ]] # Trailing space
|
||||||
```
|
```
|
||||||
|
|
||||||
### Correct code:
|
### Correct code:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
[[ "${var}" == "value" ]] # Correct variable expansion
|
[ $((var+1)) == 5 ] # Evaluated math
|
||||||
[[ "$(cmd1 | cmd2)" == "42" ]] # Correct command substitution
|
[ "${var}" == "value" ] # Correct variable expansion
|
||||||
[[ "$var" == *.png ]] # No trailing space
|
[ "$(cmd1 | cmd2)" == "42" ] # Correct command substitution
|
||||||
|
[[ "$var" == *.png ]] # No trailing space
|
||||||
```
|
```
|
||||||
### Rationale:
|
### Rationale:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user