shellcheck
shellcheck copied to clipboard
[Feature Request] Ignore this line
For new checks and feature suggestions
- [x] https://www.shellcheck.net/ (i.e. the latest commit) currently gives no useful warnings about this
- [x] I searched through https://github.com/koalaman/shellcheck/issues and didn't find anything related
feature request
We can ignore an error like this:
# shellcheck disable=SC2010
files=$(ls -l | grep foo)
In most modern analyser tools it's possible to do something like this:
files=$(ls -l | grep foo) # shellcheck disable=SC2010
That means "ignore this line", rather than "ignore next line".
Caveat: for multi-lines, it would either apply to the whole command - or if that's too complicated, just specify that the "ignore this line" feature does not apply to multiline commands.
This way of doing things would tidy scripts, make them more readable and thus more maintainable.
Please consider this. Thanks!
I agree this would be nice, to explicitly ignore a check.
If this check were really smart, it would automatically not complain about ls -l
, because in most cases you'd want to grep the output of ls -l
it is because you want to check the metadata of a file, not the filename(s). Other than an explicit stat
, this is very hard to do otherwise, so it should definitely be added to the documentation as a valid exception, but better would be to reduce the severity of this warning or even not warn at all when ls -l
is used, rather than ls *foo
.
I have something like this for testing a private container.
echo 'test-user:$1$mIRYITE9$ZPHhh4.C6YKU.XlS1jMfM.:17370:0:99999:7:::' >> /etc/shadow
or to generate some content
echo '$100 USD'
note: Expressions don't expand in single quotes, use double quotes for that. [SC2016]
Maybe this is a different issue... and anything starting with $DIGIT
should be ignored by default.
I now see that SC2016 has a lot of other false positives