[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#26005: bug in grep

From: Stephane Chazelas
Subject: bug#26005: bug in grep
Date: Tue, 7 Mar 2017 14:17:06 +0000
User-agent: Mutt/1.5.24 (2015-08-30)

2017-03-06 16:44:01 -0600, Eric Blake:
> > To reproduce run in empty directory
> > 
> > echo "start_string_20091210.end" | grep -o
> > [1-2][0][0-1][0-9][0-1][0-9][0-3][0-9]
> Underquoted.  This asks the shell to perform globbing for all files that
> match those patterns.  Initially, none do, so the shell passes the
> pattern on unchanged to grep.

For completeness, that happens with most shells but not fish
where [...] is not a glob operator.

Also, with zsh, csh, tcsh and pre-Bourne shells, you would have
had a "not found" error as the glob doesn't match any file that
would have helped identify the source of problem earlier.

That was /broken/ by the Bourne shell in the late seventies that
instead passes the glob unexpanded to the command when it
doesn't match any file. All Bourne-like shells except zsh, and
rc-like shells are /broken/ in the same way. fish doesn't have
the issue (for its own globs that don't include [...]).

In recent versions of bash, you can do:

shopt -s failglob

to get the /better/ behaviour.

See also
for more information on that.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]