GNU bug report logs - #54174
(MacOS Monterey 12.2.1: zsh): grep "string" * is interpreted as grep -V when directory has a filename "-Vfilename.ext"

Previous Next

Package: grep;

Reported by: Marja Koivunen <marja <at> innomore.com>

Date: Sat, 26 Feb 2022 22:33:02 UTC

Severity: normal

Done: Bob Proulx <bob <at> proulx.com>

Bug is archived. No further changes may be made.

Full log


Message #22 received at 54174 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Marja Koivunen <marja <at> innomore.com>
Cc: 54174 <at> debbugs.gnu.org
Subject: Re: bug#54174: (MacOS Monterey 12.2.1: zsh): grep "string" * is
 interpreted as grep -V when directory has a filename "-Vfilename.ext"
Date: Sun, 27 Feb 2022 15:22:29 -0800
[Message part 1 (text/plain, inline)]
On 2/27/22 11:31, Marja Koivunen wrote:
> Maybe what is possible is to add a line to manual that explains that certain filenames that are OK in modern OS might not work with grep.
> 
> I have used “-" sometimes to keep certain file at the top of directory hierarchy. In this case I was organizing libraries and marked those that I was not using with “-“.

Although that practice is tempting, it is probably not a good idea on 
any platform where you might use shell commands. POSIX says portable 
file names can't begin with '-'.

There is a section of the grep manual that talks about this but perhaps 
it is not clear enough. I installed the attached patch to try to make it 
better.
[0001-doc-more-on-leading.patch (text/x-patch, attachment)]

This bug report was last modified 3 years and 83 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.