Re: [PATCH] expand: Recognize '^' as a negation character in BE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 16/07/2021 10:42, Dimitar Yurukov wrote:
While parsing bracket expression ('[...]'), DASH recognizes only '!' as
a special character for negation/inversion, but POSIX specifies '^'.

The POSIX specification (2018 edition) states:

   ^ The <circumflex> shall signify a non-matching list expression when
     it occurs first in a list, immediately following a
     <left-square-bracket> (see RE Bracket Expression).

It also states:

the <exclamation-mark> character ( '!' ) shall replace the <circumflex> character ( '^' ) in its role in a non-matching list in the regular expression notation

and

A bracket expression starting with an unquoted <circumflex> character produces unspecified results.

See 2.13.1 Patterns Matching a Single Character.

So both the dash and the bash behaviour are permitted and this patch does not address a correctness issue. Scripts that rely on ^ for negation should be modified to use !.

The patch may still be worthwhile to increase compatibility, but in that case the same change also needs to be made to expmeta().

Cheers,
Harald van Dijk



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux