2022-01-19 16:37:54 +1100, Herbert Xu: [...] > This patch forces ^ to be a literal when we use fnmatch. [...] Hi, I'm coming here from a discussion at https://www.austingroupbugs.net/view.php?id=1558 where I'm trying to get POSIX to mandate (or suggest that it will mandate in the future) [^x] works like [!x] to negate a bracket expression set like it does already in most shell/fnmatch()/glob() implementations, and to remove that non-sensical (to me at least) discrepancy with regexps and most other shells / languages. To me, that patch is a step in the wrong direction. Other Ash-based shells already made the move (make [^x] an alias for [!x]) a long time ago (FreeBSD / NetBSD sh in 1997), BSD fnmatch() in 1994. The GNU libc and GNU shell have always supported [^x] AFAIK. So has zsh. ksh made the move in 2005. In dash, the move to fnmatch() in that case was a step in the right direction, and reverting it would be an unfortunate step back to me. If the point of having dash use fnmatch() is to add consistency with other tools used from the shell (like find -name/-path...), then this change doesn't help either on the majority of systems. The "fix" also seems incomplete and causes at least this regression: $ ltrace -e fnmatch ./bin/dash -c 'case "\\" in ($1) echo match; esac' sh '[\^]' dash->fnmatch("[\\\\^]", "\\", 0) = 0 match See how that added \ caused it to be included in the set. Compare with: +++ exited (status 0) +++ $ ltrace -e fnmatch ./bin/dash -c 'case "\\" in ($1) echo match; esac' sh '[\!]' dash->fnmatch("[\\!]", "\\", 0) = 1 +++ exited (status 0) +++ $ ltrace -e fnmatch ./bin/dash -c 'case "\\" in ($1) echo match; esac' sh '[\x]' dash->fnmatch("[\\x]", "\\", 0) = 1 +++ exited (status 0) +++ (here on Debian with glibc 2.33) -- Stephane