.. are always ignored when
GLOBIGNORE is set and not null.
Most of the time, it is not desirable to include
.. as wildcard matches, since they don't represent files inside the directory — they're hacks to make directory navigation work. In fact, the origin of dot files is a bug in an early version of the
ls command. The author meant to exclude
.. from the listing but accidentally excluded all files that begin with
.. Thus dot files became hidden from
ls. Shells followed suit by hiding dot files like
ls. However the way this was done was again a hack: files beginning with
. are only excluded if the dot isn't matched explicitly in the pattern. So the pattern
To preserve compatibility with existing scripts, modern shells still include
.. (except zsh, which on this issue like many others has a saner but not backward compatible behavior). However, if you set
GLOBIGNORE, you are using a bash-specific feature, which shows that you aren't interested in backward compatibility. So pattern matching changes to exclude
.. from all pattern matches.
GLOBIGNORE=. excludes a file that is excluded automatically anyway whenever
GLOBIGNORE is set, so it is equivalent to
shopt -s dotglob except that
.. are furthermore excluded from all patterns.