GNU bug report logs -
#41262
Weird behavior with grep regex
Previous Next
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 #7 received at control <at> debbugs.gnu.org (full text, mbox):
tag 41262 notabug
thanks
On 5/14/20 8:57 AM, 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
> $
>
>
> Any idea ?
Improper quoting. Notice:
$ rm -f ?
$ echo [a-z]
[a-z]
$ echo "[a-z]"
[a-z]
$ touch t
$ echo [a-z]
t
$ echo "[a-z]"
[a-z]
your shell is globbing [a-z] when there is a filename for it to match.
The globbing happens prior to the execution of grep, so it is not grep's
fault ('echo a | grep t' correctly outputs no match), therefore I'm
closing this as not a bug. But feel free to reply if you have further
questions on the topic.
> Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
Disclaimers like this are unenforceable on publicly-archived lists, and
don't add anything useful to the conversation. It may be nicer to send
mails from a personal account that does not slam us with your employer's
legalese.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
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.