GNU bug report logs - #37753
wish for glob(7)-like matcher

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: grep; Severity: wishlist; Reported by: "Trent W. Buck" <trentbuck@HIDDEN>; dated Tue, 15 Oct 2019 01:44:01 UTC; Maintainer for grep is bug-grep@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 Nov 2019 18:05:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 13 13:05:15 2019
Received: from localhost ([127.0.0.1]:60133 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iUx11-0002ZY-1i
	for submit <at> debbugs.gnu.org; Wed, 13 Nov 2019 13:05:15 -0500
Received: from lists.gnu.org ([209.51.188.17]:58127)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <gcggb-bug-grep@HIDDEN>) id 1iUx0z-0002ZR-SN
 for submit <at> debbugs.gnu.org; Wed, 13 Nov 2019 13:05:14 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:33290)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <gcggb-bug-grep@HIDDEN>) id 1iUx0y-0004Zu-EX
 for bug-grep@HIDDEN; Wed, 13 Nov 2019 13:05:13 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: **
X-Spam-Status: No, score=2.2 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 KHOP_HELO_FCRDNS,RDNS_DYNAMIC autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <gcggb-bug-grep@HIDDEN>) id 1iUx0x-0003E3-Ct
 for bug-grep@HIDDEN; Wed, 13 Nov 2019 13:05:12 -0500
Received: from 195-159-176-226.customer.powertech.no ([195.159.176.226]:40314
 helo=blaine.gmane.org)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <gcggb-bug-grep@HIDDEN>)
 id 1iUx0x-00039y-5V
 for bug-grep@HIDDEN; Wed, 13 Nov 2019 13:05:11 -0500
Received: from list by blaine.gmane.org with local (Exim 4.89)
 (envelope-from <gcggb-bug-grep@HIDDEN>) id 1iUx0u-000Ab4-8z
 for bug-grep@HIDDEN; Wed, 13 Nov 2019 19:05:08 +0100
X-Injected-Via-Gmane: http://gmane.org/
To: bug-grep@HIDDEN
From: Stephane Chazelas <stephane.chazelas@HIDDEN>
Subject: Re: bug#37753: wish for glob(7)-like matcher
Date: Wed, 13 Nov 2019 18:00:50 +0000
Message-ID: <20191113180050.zunrwsfjmcxmg4pf@HIDDEN>
References: <20160201071906.8528.29704.reportbug@frey>
 <20160201071906.8528.29704.reportbug@frey>
 <20190926150716.GA30404@bartik> <20191015014312.GA2797@HIDDEN>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
User-Agent: NeoMutt/20171215
Content-Disposition: inline
In-Reply-To: <20191015014312.GA2797@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-Received-From: 195.159.176.226
X-Spam-Score: -0.8 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.8 (-)

2019-10-15 12:43:14 +1100, Trent W. Buck:
[...]
> > GNU grep already has options for fixed strings (-F),
> > and BRE, ERE and PCRE.  Can we have one for glob(7)?
> >
> > AFAICT nobody has asked for this before; this surprises me,
> > because it "feels" like it should be easy to implement.
> >
> > Am I wrong?
[...]

For the record, ast-open's "grep" has 

  -K, --ksh-regexp
	ksh(1) extended file match patterns.

That's ksh93 wildcards, a superset of bash -O extglob ones
(themselves shaped after ksh88's globs) with same feature level
as regexps.

$ echo abcde | ast-grep -Ko '?c?'
bcd


You can always define a POSIX shell function like:

fnmatch() (
  pattern=${1?}; shift
  cat -- "$@" | while IFS= read -r line || [ -n "$line" ]; do
    case $line in ($pattern) printf '%s\n' "$line"
  done
)

(though that will be very slow, especially with shells that
don't have "printf" or "[" builtin; and except in zsh, it won't
work properly with input containing NUL bytes).

Note that there is some variation in wildcard syntax from one
shell to the next and one or from one fnmatch() to the next
(though they generally support the minimum POSIX set at least).

There's also the question of whether you'd want to consider \ as
an escape operator (again YMMV depending on the shell for that
fnmatch() function above).

-- 
Stephane






Information forwarded to bug-grep@HIDDEN:
bug#37753; Package grep. Full text available.

Message received at 37753 <at> debbugs.gnu.org:


Received: (at 37753) by debbugs.gnu.org; 13 Nov 2019 04:23:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 12 23:23:44 2019
Received: from localhost ([127.0.0.1]:58718 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iUkBz-0008Ts-7A
	for submit <at> debbugs.gnu.org; Tue, 12 Nov 2019 23:23:44 -0500
Received: from youngberry.canonical.com ([91.189.89.112]:60640)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <seth.arnold@HIDDEN>) id 1iUjA1-0006kW-Da
 for 37753 <at> debbugs.gnu.org; Tue, 12 Nov 2019 22:17:37 -0500
Received: from 97-120-111-46.ptld.qwest.net ([97.120.111.46] helo=localhost)
 by youngberry.canonical.com with esmtpsa
 (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2)
 (envelope-from <seth.arnold@HIDDEN>) id 1iUj9v-0004Ly-Bi
 for 37753 <at> debbugs.gnu.org; Wed, 13 Nov 2019 03:17:31 +0000
Date: Wed, 13 Nov 2019 03:17:29 +0000
From: Seth Arnold <seth.arnold@HIDDEN>
To: 37753 <at> debbugs.gnu.org
Subject: glob in grep
Message-ID: <20191113031729.GB17080@millbarge>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 37753
X-Mailman-Approved-At: Tue, 12 Nov 2019 23:23:42 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -6.0 (------)

Hello, I know I've wanted this feature before, if for nothing else an easy
way to test various glob patterns against various inputs without having to
create a bunch of files in the filesystem.

Thanks




Information forwarded to bug-grep@HIDDEN:
bug#37753; Package grep. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 15 Oct 2019 01:43:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 14 21:43:26 2019
Received: from localhost ([127.0.0.1]:42488 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iKBry-0003HV-Cc
	for submit <at> debbugs.gnu.org; Mon, 14 Oct 2019 21:43:26 -0400
Received: from mail-pf1-f182.google.com ([209.85.210.182]:38859)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <trentbuck@HIDDEN>) id 1iKBrw-0003HH-IW
 for submit <at> debbugs.gnu.org; Mon, 14 Oct 2019 21:43:24 -0400
Received: by mail-pf1-f182.google.com with SMTP id h195so11390805pfe.5
 for <submit <at> debbugs.gnu.org>; Mon, 14 Oct 2019 18:43:24 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=date:from:to:subject:message-id:references:mime-version
 :content-disposition:in-reply-to:user-agent;
 bh=4FX3HHGei5mywpYiP76R7u64rEt3Lp/quqyl8mcOnpI=;
 b=apxEg8o0gDgha5vi8zndD3JmLvmFkPMtVXp8TCoWoJvSIdaJk0yT9V9jrMRSDTOf9G
 KASeLeHwulD3L7d/QEdTHLlSc7B3louE+6vTH+Ce04TmWWSCaBGoFr1tAZoPnOn8Kq5K
 pismdU0V1dnXje0BqAJ4E4E8xKBCO/aweESNGgTchH1AZNxvOQrM2GP5bV90fgKa8+NV
 nU4Mb67659bZfJ5M8A0QL+MzrtZvKdj5qUf8d8ozrce2cyHsV7hHlNcfnuJfK70bgBBd
 WB6XzUoWEztck6XhPPdxqPBtNJQNquBRbM1Po+ZJNKh/bqNxjIunAIIC3qrOUwxB4Jh8
 R+OQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:date:from:to:subject:message-id:references
 :mime-version:content-disposition:in-reply-to:user-agent;
 bh=4FX3HHGei5mywpYiP76R7u64rEt3Lp/quqyl8mcOnpI=;
 b=Cw9CXBOrf1TqYsVtp6vrQtLVEDka7SWyKrYuvUccjeAplIksMLwDVxfK05rnfDh8Jj
 J1x7CFDtDbkoLjNq66/jCfJpFkPkHg5mY+jm4UUHTOaUbFSzTO3Y7eYq3VX3kw8RIB7I
 zC1wCnqlygoXGFM7C9l0ita91yItXBTCpKjFbRiUcildGYEeEzKsBnet+8QahDFnFYu/
 O/cmE5tWyQRqi42yi9FVClCfmL06tILR7XK2/EIZmAU5l//eB+cIVvCQLsp61GedNhaP
 nf6hPyMToAYWHPLYVyT/AS712liK7pUsZ7vhqgfUe5+VQnH4N1/8n01TQ4fY9wmRSH+I
 ZpPw==
X-Gm-Message-State: APjAAAUw3M8Ggl/jWedAcjs2Xkpga/H0/xoTH3EU3oXHbcmoVGq+FKMB
 pDsDGclElEjMnRZ3LukJI1gWPZvX
X-Google-Smtp-Source: APXvYqy0MDVtvVDHd0sdyfEUrjNviS5GCG9pQgzyguyGwBXy1v6LCKYj+9OMOhpnH90FHDyEd29AYg==
X-Received: by 2002:a62:e40d:: with SMTP id r13mr35640718pfh.154.1571103798115; 
 Mon, 14 Oct 2019 18:43:18 -0700 (PDT)
Received: from localhost ([203.7.155.117])
 by smtp.gmail.com with ESMTPSA id m12sm23121691pff.66.2019.10.14.18.43.16
 for <submit <at> debbugs.gnu.org>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 14 Oct 2019 18:43:17 -0700 (PDT)
Date: Tue, 15 Oct 2019 12:43:14 +1100
From: "Trent W. Buck" <trentbuck@HIDDEN>
To: submit <at> debbugs.gnu.org
Subject: wish for glob(7)-like matcher
Message-ID: <20191015014312.GA2797@HIDDEN>
References: <20160201071906.8528.29704.reportbug@frey>
 <20160201071906.8528.29704.reportbug@frey>
 <20190926150716.GA30404@bartik>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20190926150716.GA30404@bartik>
User-Agent: Mutt/1.10.1 (2018-07-13)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Package: grep
Version: 2.20-4
Severity: wishlist
Tags: upstream

This bug was originally reported as
https://bugs.debian.org/813356

I am attempting to upstream it into bugs.gnu.org.

PS: nowadays I also know to mention fnmatch(3).


On Mon, 01 Feb 2016 18:19:06 +1100 "Trent W. Buck" <trentbuck@HIDDEN> wrote:
> Sometimes I want to match globs instead of regexps.
> glob(7) explicitly says:
>   "they match filenames, rather than text"
> I don't see why globs shouldn't be used for text.
>
>
> In bash this is ugly and *SLOW*, e.g.
>
>     # Print log lines that match no "whitelisted" patterns.
>     while read -r line
>     do
>         if ! [[ line = glob1 || line = glob2 || ... ]]
>         then echo "$line"
>         fi
>     done <log
>
> instead of
>
>     grep --basic-glob -vf whitelist log
>
>
> GNU grep already has options for fixed strings (-F),
> and BRE, ERE and PCRE.  Can we have one for glob(7)?
>
> AFAICT nobody has asked for this before; this surprises me,
> because it "feels" like it should be easy to implement.
>
> Am I wrong?
>
> Is there a good reason to WONTFIX this?
>
>
>
> I asked my peers and the only real counterargument I got was
> "just learn regexps, you'll need them eventually".
>
> For my use case, I think globs would be more readable (esp. not having
> to escape dots and parens), and easier to teach to non-technical staff.
> (I haven't trialled it yet, because I don't have a globber that's as
> fast as GNU grep is for regexps.)
>
>
> PS: I'd have directly reported this upstream,
> but https://sv.gnu.org/bugs/?group=grep says I must be a "project member",
> and I'm not.




Acknowledgement sent to "Trent W. Buck" <trentbuck@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-grep@HIDDEN. Full text available.
Report forwarded to bug-grep@HIDDEN:
bug#37753; Package grep. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

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