[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#56453: 回复: bug#56453: Bug reports
From: |
Paul Jackson |
Subject: |
bug#56453: 回复: bug#56453: Bug reports |
Date: |
Sat, 09 Jul 2022 21:35:09 -0500 |
User-agent: |
Cyrus-JMAP/3.7.0-alpha0-720-gbf5afa95ff-fm-20220708.001-gbf5afa95 |
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@usa.net
bug#56453: Bug reports, Gary Johnson, 2022/07/08