For new checks and feature suggestions
Here's a snippet or screenshot that shows a potential problem:
#!/bin/bash
set -eo pipefail
seq 100000 | head
echo unreachable
Here's what shellcheck currently says:
nothing.
Here's what I wanted to see:
-:3:14: warning: This may send SIGPIPE and abort execution
OK commands
cat
cut
fold
grep without -q etc
od
paste
sha1sum etc
shuf
sort
tac
tail
tr
uniq
commands that may send SIGPIPE
Of course SIGPIPE is not sent when the grep patten does not match or piped data is small enough (< 1 MiB).
commands that may send SIGPIPE (unclear)
It is hard to check awk and sed because it depends on the script bodies (and awk implementation):
seq 100000 |
awk -f scriptfile
# ^~ This may send SIGPIPE and abort execution, depending on the script
and eventually
seq 100000 |
unknown-command
# ^~ ShellCheck does not know this command and cannot guarantee that SIGPIPE will not sent
# if ShellCheck knows that the command does not read stdin, SC2216 will be issued
For new checks and feature suggestions
Here's a snippet or screenshot that shows a potential problem:
Here's what shellcheck currently says:
nothing.
Here's what I wanted to see:
OK commands
catcutfoldgrepwithout-qetcodpastesha1sumetcshufsorttactailtruniqcommands that may send SIGPIPE
grep -qetc (pipefailandgrep -qwont get along well #665; Add SC2337: warn about grep early exit in pipelines under pipefail #3498)head(warning against piping to head #429) → safe alternatives aresed -n -e '1,10p',sed -e '11,$d'orawk 'NR <= 10'Of course SIGPIPE is not sent when the grep patten does not match or piped data is small enough (< 1 MiB).
commands that may send SIGPIPE (unclear)
nawk—exitsed—qIt is hard to check awk and sed because it depends on the script bodies (and awk implementation):
and eventually