Skip to content

no-ps-grep

Shellstyleno fixdefault: offshell/shellcheck

Reports a pipeline from ps into grep.

ps | grep name also matches the grep process itself, and any process whose command line contains the text, so the test is true when nothing runs.

To fix, use pgrep name.

Reported
...
trap 'rm $tmp' EXIT
trap "echo bye" EXIT
...
ps aux | grep nginx
...
shell:
lint:
rules:
no-ps-grep: warn # off (default), warn, error

Enabled by the presets: shell/shellcheck.

Suppress one line with sudsy-disable-next-line no-ps-grep in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
shellcheck SC2009 full