mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC3026 (markdown): POSIX issue and unspecified behavior
@@ -16,7 +16,7 @@ echo foo-[!0]*.jpg
|
||||
|
||||
`[^c]` is frequently used in most regular expression variants to mean "any character except `c`". Ksh and Bash adopted it for globs as well.
|
||||
|
||||
However, strictly speaking, the only range complement syntax guaranteed to be supported across shells is `[!c]`. Dash used to support `[^c]` when compiled with `fnmatch` and `glob` from glibc, but it was considered as a [bug](https://lore.kernel.org/dash/09fd70edcf08c75b4f9f2e158e3e6c0832d35d90.camel@scientia.org/t/#u) and fixed in version 0.5.12. Busybox has a similar [bug 14516](https://bugs.busybox.net/show_bug.cgi?id=14516).
|
||||
However, strictly speaking, the only range complement syntax guaranteed to be supported across shells is `[!c]`. POSIX explicitly states that behavior of `[^c]` is unspecified. Dash used to support `[^c]` when compiled with `fnmatch` and `glob` from glibc, but it was considered as a [bug](https://lore.kernel.org/dash/09fd70edcf08c75b4f9f2e158e3e6c0832d35d90.camel@scientia.org/t/#u) and fixed in version 0.5.12. Busybox has a similar [bug 14516](https://bugs.busybox.net/show_bug.cgi?id=14516).
|
||||
|
||||
### Exceptions:
|
||||
|
||||
@@ -26,5 +26,6 @@ Or just rewrite it to be on the technically correct side.
|
||||
|
||||
### Related resources:
|
||||
|
||||
* [2.13.1 Patterns Matching a Single Character](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13_01) in the Shell and Utilities (XCU) volume of POSIX.1-2017
|
||||
* [2.13.1 Patterns Matching a Single Character](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13_01) in the Shell and Utilities (XCU) volume of POSIX.1-2017.
|
||||
* [0001558: require `[^...]` in addition to `[!...]` for bracket expression negation](https://www.austingroupbugs.net/view.php?id=1558) POSIX enhancement request was rejected.
|
||||
* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
|
||||
|
Reference in New Issue
Block a user