bug-bash
[Top][All Lists]
Advanced

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

Re: !(.pattern) can match . and .. if dotglob is enabled


From: Chet Ramey
Subject: Re: !(.pattern) can match . and .. if dotglob is enabled
Date: Thu, 27 May 2021 15:02:14 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.2

On 5/26/21 7:36 PM, Nora Platiel wrote:
Hello,

This is behavior that changed more than ten years ago.

I thought it changed in this commit:
https://git.savannah.gnu.org/cgit/bash.git/commit/?id=ac50fbac377e32b98d2de396f016ea81e8ee9961
2014-02-26 -> 7.2 years ago

That's the commit to the master branch when bash-4.3 was released. The
actual change, captured in the `devel' branch that tracks bash development,
happened sometime in 2011.

But yes, I know it's old stuff and I was not implying a regression, just 
mentioning it FYI.

There was a relevant discussion back in January:
https://lists.gnu.org/archive/html/bug-bash/2021-01/msg00240.html

Thanks, I did a search but I missed it.
It *is* relevant, because I think that @(?|.?) matching '.' is consistent with 
!(.foo) matching '.' and '..'

OK, so we're saying the same thing at this point.

The problem is, there is nothing in the docs that hints at such behavior.
I.e. that the pattern beginning with a literal dot may not match at all, but it 
still signal that '.' and '..' should be accepted in the final match.

How would you improve the wording? What do you think is most important to
cover?


So why it does here?
$ shopt -s dotglob; echo @(.foo|*)
. .. .a b
$ shopt -u dotglob; echo @(.foo|*)
b

It's not intuitive. The dotglob causes all files starting with `.' to be
in the list, the .foo pattern keeps `.' and `..' from being discarded,
and the `*' matches it (since dotglob disables the requirement that an
initial `.' be matched explicitly).

Can you write a set of rules that encapsulates what you would like to see?
Or can the group?


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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