koalaman / shellcheck

ShellCheck, a static analysis tool for shell scripts
https://www.shellcheck.net
GNU General Public License v3.0
36.16k stars 1.77k forks source link

warn about 'grep pattern' without specifying filename #567

Open bittorf opened 8 years ago

bittorf commented 8 years ago

like https://github.com/koalaman/shellcheck/issues/452 we should warn about a forever hanging grep, e.g.

grep mypattern

or

grep -switches mypattern

with a forgotten filename.

deryni commented 8 years ago

GNU grep as of some version 2.11 (changelog entry) assumes that a missing filename means the current directory when run with the -r, --recursive flag.

bittorf commented 8 years ago

@deryni interesting - thanks, the feature is from march 2012 and it is not POSIX 8-) so still a valid case and a warning should be OK. for interactive scripting it's OK to leave the filename blank, but for real you should do a

grep -r PATTERN ./
deryni commented 8 years ago

I agree completely. I just wanted to point out that it is technically valid (for GNU grep).