On Thu, 30 Apr 2015, Stuart Henderson wrote:

On 2015/04/30 07:51, Martin Natano wrote:
grep reads from standard input when no files are specified. It also does
so when -R is used, which doesn't really make sense. I think using the
current working directory as a fallback when no directories are
specified would make sense. POSIX says "If no file operands are
specified, the standard input shall be used.", but -R is an extension
to POSIX, so I guess it is not bound by that.

Far too often I've started a grep -R and waiting for the output, only to
recognize minutes later, that I forgot to add the '.' at the end of the
command and it is reading from stdin.

It's an extension, and it might not make sense to you (though I can
imagine counter-arguments), but the current behaviour matches other
common greps in use - deviating from this seems like a bad idea.

It also matches behaviour of gzip(1) (gzip -r) and other tools, like find(1) or tar(1).

Regards,
David

Reply via email to