Hey. Assuming a pattern of: [.*^\] my understanding was that this would actually mean: - the literal string [. followed by - the pattern notation special character * (i.e. any string) followed by - the literal string ^] Because ] is escaped, it's to be taken literally and in a pattern a [ without corresponding ] is to be taken literally as well. (see POSIX, https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13 ) That seems to work in busybox sh: $ case '[.^]' in ([.*^\]) echo match;; (*) echo no match;; esac match $ case '[.x^]' in ([.*^\]) echo match;; (*) echo no match;; esac match $ case '[.xx^]' in ([.*^\]) echo match;; (*) echo no match;; esac match However, adding another [ to the pattern: [.*^[\] which should be: - the literal string [. followed by - the pattern notation special character * (i.e. any string) followed by - the literal string ^[] No longer matches: $ case '[.^[]' in ([.*^[\]) echo match;; (*) echo no match;; esac no match $ case '[.x^[]' in ([.*^[\]) echo match;; (*) echo no match;; esac no match $ case '[.xx^[]' in ([.*^[\]) echo match;; (*) echo no match;; esac no match Whereas, AFAIU POSIX, it should. This works, btw. in bash, but neither in dash, nor klibc sh. Cheers, Chris.
If busybox sh would use glibc's fnmatch() for this, then this may also be a bug there. See: https://lore.kernel.org/dash/YeZbt7nhvODBSL0I@gondor.apana.org.au/T/#m090520913643547feccac71ed6e6f48219fb5988 respectively: https://sourceware.org/bugzilla/show_bug.cgi?id=28792