[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: Wed, 26 May 2021 11:44:04 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.1

On 5/25/21 8:58 PM, Nora Platiel wrote:

Bash Version: 5.1
Patch Level: 8
Release Status: release


$ shopt -s dotglob extglob
$ echo !(.foo)
. .. .other files

The doc says: "The filenames '.' and '..' must always be matched explicitly, even if 
dotglob is set."

When dotglob is enabled, the shell's pattern matcher interprets an extglob
pattern beginning with a literal `.' as specifying that files beginning
with a `.' should match, so the negated pattern matches `.' and `..'.

Also the pattern !(.foo) didn't match . and .. before version 4.3.0.

This is behavior that changed more than ten years ago.

There was a relevant discussion back in January:


``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]