mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC2124 (markdown)
@@ -48,7 +48,7 @@ Since doing this usually indicates a bug, ShellCheck warns and asks you to be ex
|
|||||||
|
|
||||||
If you want to assign N elements as N elements in Bash or Ksh, use an array, e.g. `myArray=( "$@" )`.
|
If you want to assign N elements as N elements in Bash or Ksh, use an array, e.g. `myArray=( "$@" )`.
|
||||||
|
|
||||||
Dash and POSIX sh do not support arrays. In this case, either concatenate the values with some delimiter that you can split on later (the example uses linefeeds and splits them back up with a `while read` loop), or keep the values as positional parameters without putting them in an array.
|
Dash and POSIX sh do not support arrays. In this case, either concatenate the values with some delimiter that you can split on later (the example uses linefeeds and splits them back up with a `while read` loop), or keep the values as positional parameters without putting them in an intermediate variable.
|
||||||
|
|
||||||
If you want to assign N elements as 1 element by concatenating them, use `*` instead of `@`, e.g. `myVar=${myArray[*]}` (this separates elements with the first character of `IFS`, usually space).
|
If you want to assign N elements as 1 element by concatenating them, use `*` instead of `@`, e.g. `myVar=${myArray[*]}` (this separates elements with the first character of `IFS`, usually space).
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user