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


View this message in rfc822 format

From: Marja Koivunen <marja <at> innomore.com>
To: 54174 <at> debbugs.gnu.org
Subject: 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 14:31:29 -0500
[Message part 1 (text/plain, inline)]
Ok. I understand it is not possible to make “-V “ instead of “-Vfilename” because so many existing scripts rely on thatgrept works a certain way.

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 “-“.


Here is command-line example that you asked.



Even looked from the manual the simple example and did not see what I was doing wrong (I did not read the whole manual.)
So if the program user interface cannot be changed maybe the manual could tell that filenames that start with “-“ might require some additional quoting....

Marja

********* No need to reply *********




On Feb 26, 2022, at 1:33 PM, Marja Koivunen <marja <at> innomore.com> wrote:

I had a directory with filenames that started with “-“

doing grep on that directory for a “string" did not find anything
although “string was on some of the files”

grep just kept repeating something … FreeBSD

Finally, (with some help) I understood that grep interpreted “-Vfiename” as an option -V and 
gave the version info instead of doing grep “string” *

Maybe there is a way to add space after “-V “ and possibly also other options that could be used as  part of a filename in some operating systems?
[Message part 2 (text/html, inline)]
[Screen Shot 2022-02-27 at 1.57.54 PM.png (image/png, inline)]
[Screen Shot 2022-02-27 at 1.46.18 PM.png (image/png, inline)]

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.