no-ls-grep
What it does
Section titled “What it does”Reports a pipeline from ls into grep.
Why it matters
Section titled “Why it matters”ls output is for people and grep matches lines, so a file name with a newline is split and one that looks like a line of output is matched wrongly. A glob or find selects names without parsing text.
To fix, use a glob (ls *foo*, or for f in *foo*) or find.
Example
Section titled “Example”...trap 'rm $tmp' EXITtrap "echo bye" EXITls | grep txt...[ -n x ] && (a || b)a && ba || b && cls -l | grep txt | wc -l...Configuration
Section titled “Configuration”shell: lint: rules: no-ls-grep: warn # off, warn (default), errorEnabled by the presets: shell/shellcheck.
Suppress one line with sudsy-disable-next-line no-ls-grep in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| shellcheck | SC2010 |
full |