[Top][All Lists]

[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:

This is behavior that changed more than ten years ago.

I thought it changed in this commit:
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:

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

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

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]