mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Show examples of how this works with globs, and warn about POSIX
12
SC2125.md
12
SC2125.md
@@ -4,7 +4,11 @@
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
foo={1..9}
|
foo={1..9}
|
||||||
echo $foo
|
echo "$foo"
|
||||||
|
```
|
||||||
|
```sh
|
||||||
|
foo="/some/path/*"
|
||||||
|
echo "$foo"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Correct code:
|
### Correct code:
|
||||||
@@ -13,6 +17,12 @@ echo $foo
|
|||||||
foo=( {1..9} )
|
foo=( {1..9} )
|
||||||
echo "${foo[@]}"
|
echo "${foo[@]}"
|
||||||
```
|
```
|
||||||
|
```sh
|
||||||
|
foo=(/some/path/*)
|
||||||
|
echo "${foo[@]}"
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that either of these will trigger SC3030 ("In POSIX sh, array references are undefined") if you are using `sh` and not e.g. `bash`.
|
||||||
|
|
||||||
### Rationale:
|
### Rationale:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user