From: Christoph Anton Mitterer <calestyo@scientia.org>
To: dash@vger.kernel.org
Subject: possible wrong behaviour with patterns double [ with no closing ]
Date: Mon, 17 Jan 2022 04:23:46 +0100 [thread overview]
Message-ID: <3709ca54c9001bffd3e690695c3b44d47d50c7c8.camel@scientia.org> (raw)
Hey.
Assuming a pattern of:
[.*^\]
my understanding was that this would actually mean:
- the literal string [. followed by
- the pattern notation special character * (i.e. any string) followed by
- the literal string ^]
Because ] is escaped, it's to be taken literally and in a pattern a [
without corresponding ] is to be taken literally as well.
That seems to work in dash:
$ case '[.^]' in ([.*^\]) echo match;; (*) echo no match;; esac
match
$ case '[.x^]' in ([.*^\]) echo match;; (*) echo no match;; esac
match
$ case '[.xx^]' in ([.*^\]) echo match;; (*) echo no match;; esac
match
However, adding another [ to the pattern:
[.*^[\]
which should be:
- the literal string [. followed by
- the pattern notation special character * (i.e. any string) followed by
- the literal string ^[]
No longer matches:
$ case '[.^[]' in ([.*^[\]) echo match;; (*) echo no match;; esac
no match
$ case '[.x^[]' in ([.*^[\]) echo match;; (*) echo no match;; esac
no match
$ case '[.xx^[]' in ([.*^[\]) echo match;; (*) echo no match;; esac
no match
Whereas, AFAIU POSIX, it should.
This works, btw. in bash, but neither in busybox sh, nor klibc sh.
Cheers,
Chris.
next reply other threads:[~2022-01-17 3:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-17 3:23 Christoph Anton Mitterer [this message]
2022-01-18 6:18 ` possible wrong behaviour with patterns double [ with no closing ] Herbert Xu
2022-01-18 14:28 ` Christoph Anton Mitterer
2022-01-24 16:26 ` Christoph Anton Mitterer
2022-01-25 0:36 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3709ca54c9001bffd3e690695c3b44d47d50c7c8.camel@scientia.org \
--to=calestyo@scientia.org \
--cc=dash@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).