[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: |
Tue, 15 Jun 2021 10:19:48 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 |
On 6/6/21 6:31 AM, Ilkka Virta wrote:
Can you write a set of rules that encapsulates what you would like to see?
Or can the group?
I think it's a bit weird that !(.foo) can match . and .. when * doesn't.
The other means roughly "anything here", and the other means "anything but
.foo here",
so having the latter match things the former doesn't is surprising.
Yes, that's essentially where we ended up.
Personally, I'd just want an option to always make . and .. hidden from
globs.
You can use GLOBIGNORE for this, but you have to do a little more work.
Or rather,
to never generate . or .. as a pathname component via globbing.
I don't think it's useful -- and it's certainly incompatible -- to make
an explicit pattern like `.?' ignore `..'.
For what it's worth, Zsh, mksh and fish seem to always hide . and .. , and
at least Zsh does
that even with (.|..) orĀ @(.|..) .
Do they have the equivalent of `dotglob'?
And if we want to play this game, ksh93, dash, yash, and the BSD shells
all match `.' and `..' with patterns like `.*' and `.?'.
I tried to achieve that via GLOBIGNORE=.:.. , but that has the problem that
it forces dotglob
on, and looks at the whole resulting path, so ./.* still gives ./. and ./..
. Unless you use
GLOBIGNORE=.:..:*/.:*/.. etc., but repeating the same for all different
path lengths gets a bit
awkward.
Yes, that's the `more work' part. You have to tune it to your needs.
--
``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/