Re: Bookworm: dash shell globs don't recognise [^...] to negate a character class
On 2023-04-12 21:07:59 -0400, Greg Wooledge wrote:
> On Thu, Apr 13, 2023 at 12:12:23AM +0000, David wrote:
> > $ echo [^0-9]*
> > 11 22 <------ new behaviour by dash
>
> The [^chars] syntax is a negation in Basic and Extended Regular
> Expressions, and in bash's globs (it's a bash extension), but NOT in
> POSIX globs.
>
> The correct negation syntax in POSIX sh globs is [!chars].
It seems that [^chars] has undefined behavior (various POSIX shells
behave differently: bash, ksh93 and yash regard ^ as a negation, but
not mksh). In short, for portability, this form should not be used
in shells.
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Reply to: