Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: detect wrong placement of /dev/null redirection #3078

Open
2 tasks
Villemoes opened this issue Nov 7, 2024 · 0 comments
Open
2 tasks

feature request: detect wrong placement of /dev/null redirection #3078

Villemoes opened this issue Nov 7, 2024 · 0 comments

Comments

@Villemoes
Copy link

For bugs

For new checks and feature suggestions

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant