iterate-file-output
What it does
Section titled “What it does”Reports a for loop over the output of cat, sort, sed, head or tail.
Why it matters
Section titled “Why it matters”The output is split on blanks and globbed, not on lines, so a line with a space becomes several items, and a * in the file expands to file names.
To fix, read lines: while IFS= read -r line; do ...; done < file.
Example
Section titled “Example”...x=$(echo "a" | tr a b)...for l in $(cat file); do :; donefor l in "$@"; do :; done...Configuration
Section titled “Configuration”shell: lint: rules: iterate-file-output: warn # off (default), warn, errorEnabled by the presets: shell/shellcheck.
Suppress one line with sudsy-disable-next-line iterate-file-output 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 | SC2013 |
partial | Only a for over cat, sort, sed, head or tail output. |