Subject: bug#34126: closed (Re: bug#34126: grep v. 3.1 –unexpected error message "grep: i.: No such file or directory")

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 18 Jan 2019 20:38:02 +0000

Your bug report

#34126: grep v. 3.1 – unexpected error message "grep: i.: No such file or directory"

which was filed against the grep package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
34126: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=34126
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#34126: grep v. 3.1 – unexpected error message "grep: i.: No such file or directory"
From: Eric Blake <[email-masked]>
To: Ricky Tigg <[email-masked]>, [email-masked]
Date: Fri, 18 Jan 2019 14:37:30 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

tag 34126 notabug
thanks

On 1/18/19 2:27 PM, Ricky Tigg wrote:
> OS: *Fedora*; Component: grep.x86_64  3.1-8.fc29
> 
> Commands executed:
> 
> $ dnf list|grep -Ei langpack | grep fi.
> glibc-langpack-fi.x86_64            2.28-26.fc29         @updates
> langpacks-fi.noarch                 1.0-13.fc29          @System
> (...)
> 
> $ dnf list|grep -Ei langpack | grep fi. | grep "-fi."
> grep: i.: No such file or directory
> 
> Using grep twice in the same command, the command's last grep is expected
> to produce targets, not an STDERR. Probably an issue.

Not an issue in grep, but in your attempt to use a pattern beginning
with - in a way that grep cannot distinguish from options.  That is, you
asked grep to use the -f option, which takes an argument, so it used
"i." as the argument for -f, and failed because there is no file named
'i.' in your current directory.  (That's true whether you write -fi. or
"-fi.", because the shell strips quoting before grep sees its argv[]).

You want to use either of these formulations instead:

grep -e -fi.
grep -- -fi.

where the "-e" option says to treat the next argv[] entry as a pattern,
even if it otherwise would look like an option, and then continue
finding further options; while the "--" argument says that no more
options are present, and that all further command line arguments are
treated according to their traditional positional usage).  The
difference becomes apparent in constructs like:

grep -e -fi. -i     # greps stdin case-insensitively for "-fi."
grep -- -fi. -i     # greps file ./-i case-sensitively for "-fi."

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Subject: grep v. 3.1 – unexpected error message "grep: i.: No such file or directory"
From: Ricky Tigg <[email-masked]>
To: [email-masked]
Date: Fri, 18 Jan 2019 21:27:02 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

OS: *Fedora*; Component: grep.x86_64  3.1-8.fc29

Commands executed:

$ dnf list|grep -Ei langpack | grep fi.
glibc-langpack-fi.x86_64            2.28-26.fc29         @updates
langpacks-fi.noarch                 1.0-13.fc29          @System
(...)

$ dnf list|grep -Ei langpack | grep fi. | grep "-fi."
grep: i.: No such file or directory

Using grep twice in the same command, the command's last grep is expected
to produce targets, not an STDERR. Probably an issue.