GNU bug report logs -
#56453
Bug reports
Previous Next
Full log
Message #22 received at submit <at> debbugs.gnu.org (full text, mbox):
It might not be evident to some, but grep (and many similar commands) do NOT initially decide if a command line argument refers to a file or not by checking (with a stat(2) system call or similar) if the argument actually refers to a file.
Rather it's initial mode of operation is decided by the command line syntax.
If you ask for a recursive search, such as with a "-d recurse" action or a "-r" argument, it expects some directories and/or files to be named, within which it can look (if a file), or recurse (if a directory) to find files, which it then does by actually using a stat(2) or similar system call on the names it finds in the directories it traverses.
Otherwise grep expects some files to be named, which it can open and read, looking for the requested pattern, and in that non-recursive case, grep will complain if one of the names on the command line is a directory, not a file. It won't realize that failure, however, until it tries to open and read the named item, and fails to do so when a directory is named.
Otherwise, if neither is named, or only a "-" file is named, it tries reading stdin (file descriptor 1) for the data it should search.
--
Paul Jackson
pj <at> usa.net
This bug report was last modified 2 years and 343 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.