eval-array
What it does
Section titled “What it does”Reports an eval whose argument expands an array with [@].
Why it matters
Section titled “Why it matters”eval joins its arguments with spaces and parses the result again, so the quoting that the array elements had is lost, and an element with a space or a ; is read as code.
To fix, avoid eval: run the array as a command, "${cmd[@]}".
Example
Section titled “Example”...for l in "$@"; do :; doneeval "f ${args[@]}"...A=1 cmd "$B"A=1 cmd "$A_"...Configuration
Section titled “Configuration”shell: lint: rules: eval-array: warn # off (default), warn, errorEnabled by the presets: shell/shellcheck.
Suppress one line with sudsy-disable-next-line eval-array in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| shellcheck | SC2294 |
partial | Only ${name[@]} inside an eval command. |