[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help with pattern matching needed
From: |
Greg Wooledge |
Subject: |
Re: help with pattern matching needed |
Date: |
Wed, 12 Jan 2022 07:38:21 -0500 |
On Wed, Jan 12, 2022 at 06:33:02AM +0100, Christoph Anton Mitterer wrote:
> $ cat circumflex-test
> case "$1" in
> (['^.a'])
> echo match
> ;;
> (*)
> echo else
> esac
> $ sh run-circumflex | paste - - - - | column -t
> dash: match else else
> busybox-sh: match else else
> Does anyone have any explanation for this (other than it being a bug in
> dash/busybox-sh[0])?
The quotes are irrelevant; you should get the same results if you
remove them.
POSIX only specifies ! as the negation character for [...] ranges in globs.
Some shells also permit ^ to be used, for the comfort of people who are
used to regular expressions. Bash is one of the shells that permit ^.
The behavior of dash has changed in recent years. On Debian 11:
unicorn:~$ dash
$ case a in [^.a]) echo match;; *) echo not;; esac
not
But if I perform that same test on a much older Debian system, I get
the result "match" -- because the ^ is not treated as a range negation
character in that version.
Presumably your system is using one of the older versions of dash. The
results you see are not a bug in dash. Your expectations are simply
wrong.
- Re: help with pattern matching needed, (continued)
- Re: help with pattern matching needed, Christoph Anton Mitterer, 2022/01/10
- Re: help with pattern matching needed, Chet Ramey, 2022/01/08
- Re: help with pattern matching needed, Christoph Anton Mitterer, 2022/01/10
- Re: help with pattern matching needed, Christoph Anton Mitterer, 2022/01/11
- Re: help with pattern matching needed, Lawrence Velázquez, 2022/01/11
- Re: help with pattern matching needed, Christoph Anton Mitterer, 2022/01/11
- Re: help with pattern matching needed, Christoph Anton Mitterer, 2022/01/12
- Re: help with pattern matching needed, Christoph Anton Mitterer, 2022/01/12
- Re: help with pattern matching needed, Lawrence Velázquez, 2022/01/12
- Re: help with pattern matching needed, Christoph Anton Mitterer, 2022/01/12
- Re: help with pattern matching needed,
Greg Wooledge <=
- Re: help with pattern matching needed, Christoph Anton Mitterer, 2022/01/12
- Re: help with pattern matching needed, Greg Wooledge, 2022/01/12
- Re: help with pattern matching needed, Chet Ramey, 2022/01/12
- Re: help with pattern matching needed, Kerin Millar, 2022/01/12