Configuration Information [Automatically generated, do not change]: Machine: i686 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -g -O2 -Wno-parentheses -Wno-format-security uname output: Linux columbus 4.4.246-gentoo #2 SMP Thu Dec 31 17:31:16 -00 2020 i686 AMD Athlon(tm) XP 2800+ AuthenticAMD GNU/Linux Machine Type: i686-pc-linux-gnu
Bash Version: 5.1 Patch Level: 8 Release Status: release Hello, Repeat-By: $ shopt -s dotglob extglob $ echo !(.foo) . .. .other files The doc says: "The filenames '.' and '..' must always be matched explicitly, even if dotglob is set." I would infer that a !(...) should never match '.' and '..', because you cannot match something literally using an operator that means "anything except". The patterns .foo and [.]foo are equivalent under dotglob, therefore I would expect !(.foo) and !([.]foo) to be also equivalent. But . and .. are excluded here already: $ shopt -s dotglob extglob $ echo !([.]foo) .other files $ echo !(foo) .other files Personally I can't imagine how it can be ever useful for a pattern to match . or .. (unless the path component is literally . or ..). Therefore I always work with dotglob enabled and use [.]pattern instead of .pattern to get rid of . and .. But I don't think it makes much sense with the !(...) operator. Also the pattern !(.foo) didn't match . and .. before version 4.3.0. Regards, NP