Re: possible wrong behaviour with patterns using a quoted ^ at the start of a bracket expression

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

 



On 12/01/2022 17:47, Christoph Anton Mitterer wrote:
On Wed, 2022-01-12 at 17:20 +0000, Harald van Dijk wrote:
However, whether this is the correct approach is a matter of opinion:
dash could alternatively choose to always take ^ as a literal and
always
escape it before passing it on to fnmatch()

Well I personally think the best would to *always* take ^ literally,
whether quoted or not.

That would match the behaviour of bash and klibc sh, and also seems
more in the spirit of POSIX (which, while saying that an unquoted ^
produces undefined behaviour, also says that:
"( '!' ) shall replace the <circumflex> character ( '^' )""

... "replace", not complement.

Actually, in bash, unquoted ^ does act as negation. Same in ksh, which is the basis for a lot of POSIX. As for the spirit of POSIX, POSIX does say in the rationale that it's unspecified specifically in order to allow that:

  The restriction on a <circumflex> in a bracket expression is to allow
  implementations that support pattern matching using the <circumflex>
  as the negation character in addition to the <exclamation-mark>.

But personally, I have no opinion on which action dash should take, as long as it gets the right results for quoted ^.

Cheers,
Harald van Dijk



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

  Powered by Linux