-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Description
For bugs
- Rule Id (if any, e.g. SC1000):
- My shellcheck version (
shellcheck --versionor "online"): - The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
- I tried on https://www.shellcheck.net/ and verified that this is still a problem on the latest commit
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
Here's a snippet or screenshot that shows the problem:
I managed to write something like this
#!/bin/sh
rmdir "/foo/bar" || true 2> /dev/null
and only spotted the problem myself after the code was merged.
Here's what shellcheck currently says:
Nothing.
Here's what I wanted or expected to see:
Some warning about the /dev/null silencing being applied to a command that will never emit anything, and given the || true, was likely meant to be applied to the LHS command. So this is probably two feature requests (or easiest to do if considered like that): Output redirections applied to builtins like true, false, : are most likely useless, at least when the destination is also a known subject like /dev/null (true > file is not useless). And when a command is followed by || true , it is likely that any redirection of output applied to the RHS was meant to apply to the LHS.
Metadata
Metadata
Assignees
Labels
No labels