GNU bug report logs - #41262
Weird behavior with grep regex

Previous Next

Package: grep;

Reported by: <loic.tregouet <at> orange.com>

Date: Thu, 14 May 2020 14:38:02 UTC

Severity: normal

Tags: notabug

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


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

From: Shlomi Fish <shlomif <at> shlomifish.org>
To: <loic.tregouet <at> orange.com>
Cc: 41262 <at> debbugs.gnu.org
Subject: Re: bug#41262: Weird behavior with grep regex
Date: Thu, 14 May 2020 21:52:11 +0300
Hi Loic!

On Thu, 14 May 2020 13:57:48 +0000
<loic.tregouet <at> orange.com> wrote:

> Hi,
> 
> I've reproduced a strange behaviour of grep command when a file name of a
> single letter is present in current directory .
> 
> $ echo a | grep [a-z]
> a
> $ touch t
> $ echo a | grep [a-z]
> $ rm t
> $ echo a | grep [a-z]
> a
> $
> 

This is standard Unix shell ( sh / ksh / bash ) globbing behaviour:

https://en.wikipedia.org/wiki/Glob_%28programming%29

Quoting works:

```
[shlomif <at> localhost ~]$ cd tmp
[shlomif <at> localhost tmp]$ touch t
[shlomif <at> localhost tmp]$ echo a | grep [a-z]
[shlomif <at> localhost tmp]$ echo a | grep '[a-z]'
a
[shlomif <at> localhost tmp]$ echo a | grep "[a-z]"
a
[shlomif <at> localhost tmp]$ 
```

Also see https://perl-begin.org/topics/security/code-markup-injection/ .

> 
> Any idea ?
> 
> Regards
> 
> _________________________________________________________________________________________________________________________
> 
> Ce message et ses pieces jointes peuvent contenir des informations
> confidentielles ou privilegiees et ne doivent donc pas etre diffuses,
> exploites ou copies sans autorisation. Si vous avez recu ce message par
> erreur, veuillez le signaler a l'expediteur et le detruire ainsi que les
> pieces jointes. Les messages electroniques etant susceptibles d'alteration,
> Orange decline toute responsabilite si ce message a ete altere, deforme ou
> falsifie. Merci.
> 
> This message and its attachments may contain confidential or privileged
> information that may be protected by law; they should not be distributed,
> used or copied without authorisation. If you have received this email in
> error, please notify the sender and delete this message and its attachments.
> As emails may be altered, Orange is not liable for messages that have been
> modified, changed or falsified. Thank you.
> 

Ahem :(

-- 

Shlomi Fish       https://www.shlomifish.org/
https://www.shlomifish.org/humour/Summerschool-at-the-NSA/

Knuth is not God! Typing “God” into Google and pressing “I’m Feeling Lucky”
will not lead you to his homepage.
    — https://www.shlomifish.org/humour/bits/facts/Knuth/

Please reply to list if it's a mailing list post - https://shlom.in/reply .




This bug report was last modified 4 years and 243 days ago.

Previous Next


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