* Why zsh chose to be non-compliant in pattern matching
@ 2016-02-26 1:02 Cuong Manh Le
2016-02-26 8:43 ` Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: Cuong Manh Le @ 2016-02-26 1:02 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 572 bytes --]
POSIX documentation for pattern matching (
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13_01)
said that any quoted characters in pattern will be match literally.
AFAICT, `["!"a]` will match `!` or `a`, most of shell behave like that
except zsh (and also ksh):
case a in ["!"a]) echo 1;; esac
print nothing. While:
case b in ["!"a]) echo 1;; esac
print 1. zsh treats `["!"a]` the same as `[!a]`.
Is there any reason for this behavior?
PS: The full question can be seen here
http://unix.stackexchange.com/q/265431/38906
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Why zsh chose to be non-compliant in pattern matching
2016-02-26 1:02 Why zsh chose to be non-compliant in pattern matching Cuong Manh Le
@ 2016-02-26 8:43 ` Bart Schaefer
2016-02-29 10:00 ` Cuong Manh Le
0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2016-02-26 8:43 UTC (permalink / raw)
To: Cuong Manh Le; +Cc: Zsh hackers list
This has been changed for the forthcoming 5.3 release (no date yet).
See thread starting here:
http://www.zsh.org/mla/workers//2016/msg00202.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Why zsh chose to be non-compliant in pattern matching
2016-02-26 8:43 ` Bart Schaefer
@ 2016-02-29 10:00 ` Cuong Manh Le
2016-02-29 10:27 ` Peter Stephenson
0 siblings, 1 reply; 5+ messages in thread
From: Cuong Manh Le @ 2016-02-29 10:00 UTC (permalink / raw)
To: Bart Schaefer; +Cc: Zsh hackers list
[-- Attachment #1: Type: text/plain, Size: 470 bytes --]
Hi,
The super user in U&L site post his opinion at
http://unix.stackexchange.com/a/266394/38906
He said that the pattern matching spec is unspecified for quoted characters
inside bracket expression. What is your opinion?
Thanks.
On Fri, Feb 26, 2016 at 3:43 PM, Bart Schaefer <schaefer@brasslantern.com>
wrote:
> This has been changed for the forthcoming 5.3 release (no date yet).
> See thread starting here:
> http://www.zsh.org/mla/workers//2016/msg00202.html
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Why zsh chose to be non-compliant in pattern matching
2016-02-29 10:00 ` Cuong Manh Le
@ 2016-02-29 10:27 ` Peter Stephenson
2016-02-29 22:28 ` Martijn Dekker
0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2016-02-29 10:27 UTC (permalink / raw)
To: Zsh hackers list
On Mon, 29 Feb 2016 17:00:28 +0700
Cuong Manh Le <cuong.manhle.vn@gmail.com> wrote:
> The super user in U&L site post his opinion at
> http://unix.stackexchange.com/a/266394/38906
>
> He said that the pattern matching spec is unspecified for quoted characters
> inside bracket expression. What is your opinion?
He's talking about the standard, which indeed doesn't say anything about
the subject.
[
If an open bracket introduces a bracket expression as in XBD RE
Bracket Expression, except that the <exclamation-mark> character (
'!' ) shall replace the <circumflex> character ( '^' ) in its role
in a non-matching list in the regular expression notation, it shall
introduce a pattern bracket expression. A bracket expression
starting with an unquoted <circumflex> character produces
unspecified results. Otherwise, '[' shall match the character
itself.
There's a reference there to regular expressions, for which only
backslash quoting is valid, as far as I'm aware. Zsh has supported
that for quite a while.
I think it's more a question of current practice. It's probably
widespread enough now to be standardisable.
pws
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Why zsh chose to be non-compliant in pattern matching
2016-02-29 10:27 ` Peter Stephenson
@ 2016-02-29 22:28 ` Martijn Dekker
0 siblings, 0 replies; 5+ messages in thread
From: Martijn Dekker @ 2016-02-29 22:28 UTC (permalink / raw)
To: zsh-workers; +Cc: Peter Stephenson
Peter Stephenson schreef op 29-02-16 om 11:27:
> On Mon, 29 Feb 2016 17:00:28 +0700
> Cuong Manh Le <cuong.manhle.vn@gmail.com> wrote:
>> The super user in U&L site post his opinion at
>> http://unix.stackexchange.com/a/266394/38906
>>
>> He said that the pattern matching spec is unspecified for quoted characters
>> inside bracket expression. What is your opinion?
>
> He's talking about the standard, which indeed doesn't say anything about
> the subject.
In my view, the standard is quite clear:
"If any character (ordinary, shell special, or pattern special) is
quoted, that pattern shall match the character itself."
That sentence applies to pattern matching notation as a whole. Bracket
expressions are a part of pattern matching notation. There is no
language anywhere in the standard that excludes bracket expressions from
the sentence quoted.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13
Thanks,
- M.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-02-29 22:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-26 1:02 Why zsh chose to be non-compliant in pattern matching Cuong Manh Le
2016-02-26 8:43 ` Bart Schaefer
2016-02-29 10:00 ` Cuong Manh Le
2016-02-29 10:27 ` Peter Stephenson
2016-02-29 22:28 ` Martijn Dekker
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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).