GNU bug report logs - #68666
warning if --exclude-dir arg contains /?

Previous Next

Package: grep;

Reported by: Karl Berry <karl <at> freefriends.org>

Date: Mon, 22 Jan 2024 23:49:02 UTC

Severity: normal

To reply to this bug, email your comments to 68666 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-grep <at> gnu.org:
bug#68666; Package grep. (Mon, 22 Jan 2024 23:49:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Karl Berry <karl <at> freefriends.org>:
New bug report received and forwarded. Copy sent to bug-grep <at> gnu.org. (Mon, 22 Jan 2024 23:49:02 GMT) Full text and rfc822 format available.

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

From: Karl Berry <karl <at> freefriends.org>
To: bug-grep <at> gnu.org
Subject: warning if --exclude-dir arg contains /?
Date: Mon, 22 Jan 2024 16:48:21 -0700
Would it be crazy for  grep --exclude-dir=foo/bar  to give a warning?

Since, as I understand it, any non-trailing / in the arg can never match
since the arg is matched against the basename.

This came up when I ran grep -r --exclude="t/*.dir", thinking it would
exclude all the test output directories. Nope ... --thanks, karl.




Information forwarded to bug-grep <at> gnu.org:
bug#68666; Package grep. (Tue, 23 Jan 2024 05:38:01 GMT) Full text and rfc822 format available.

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

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Karl Berry <karl <at> freefriends.org>, 68666 <at> debbugs.gnu.org
Subject: Re: bug#68666: warning if --exclude-dir arg contains /?
Date: Mon, 22 Jan 2024 21:37:26 -0800
On 2024-01-22 15:48, Karl Berry wrote:
> Would it be crazy for  grep --exclude-dir=foo/bar  to give a warning?
> 
> Since, as I understand it, any non-trailing / in the arg can never match
> since the arg is matched against the basename.

That's not quite true, as it can match command-line arguments. For example:

  $ grep -rl . lib/* | grep '^lib/unictype/\.gitignore$'
  lib/unictype/.gitignore
  $ grep --exclude-dir=lib/unictype -rl . lib/* | grep 
'^lib/unictype/\.gitignore$'
  $

It should be possible to give useful warnings in some cases, though.

It's too bad the rules are so complicated - that's partly my fault, as 
the various options were added at different times and I didn't think 
things through as suggestions were made. Probably too late to change the 
meaning of existing options now, though.




Information forwarded to bug-grep <at> gnu.org:
bug#68666; Package grep. (Tue, 23 Jan 2024 22:25:01 GMT) Full text and rfc822 format available.

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

From: Karl Berry <karl <at> freefriends.org>
To: eggert <at> cs.ucla.edu
Cc: 68666 <at> debbugs.gnu.org
Subject: Re: bug#68666: warning if --exclude-dir arg contains /?
Date: Tue, 23 Jan 2024 15:23:50 -0700
    That's not quite true, as it can match command-line arguments. 

I see. Perhaps the manual could be a little less terse than expecting
readers to understand the difference between "name suffix" and "base
name".  Ok, it's clear in retrospect, but ...  maybe something like (not
sure I got it correct):

---
  Skip any command-line directory with a name suffix (possibly with
  several file name components) that matches the pattern @var{glob}.
  When searching recursively, skip any subdirectory whose base name
  (the last file name component) matches @var{glob}.  Ignore any
  redundant trailing slashes in @var{glob}.
  
  In other words if @var{glob} contains a @samp{/} (except for the
  ignored trailing slashes), the pattern will never match when searching
  recursively, but may match against explicit command line arguments.
---

    It should be possible to give useful warnings in some cases, though.

If glob contains a / and there are no command line args,
it seems a warning is warranted?

    Probably too late to change the meaning of existing options now,

Agreed.  --thanks, karl.




This bug report was last modified 99 days ago.

Previous Next


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