zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Martijn Dekker <martijn@inlv.org>, zsh-workers@zsh.org
Subject: Re: 'case' pattern matching bug with bracket expressions
Date: Thu, 14 May 2015 18:43:32 +0100	[thread overview]
Message-ID: <20150514184332.3803584d@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <5554D65B.8070500@inlv.org>

On Thu, 14 May 2015 18:07:39 +0100
Martijn Dekker <martijn@inlv.org> wrote:
> However, the more insidious case that bit me:
> 
> case abc in ( [] | [!a-z]* ) echo yes ;; ( * ) echo no ;; esac
> empty=''
> case abc in ( ["$empty"] | [!a-z]* ) echo yes ;; ( * ) echo no ;; esac
> 
> still produces a false positive even with the patch.

This is hairy because you're relying on whitespace performing word
splitting in a case where you don't need whitespace according to the
grammar anyway, i.e. if you have the valid expression

case abc in (["$empty"]|[!a-z]*) echo yes ;; (*) echo no ;; esac

it can only be parsed the way zsh parses it --- you'll find bash does
the same.

I'll have a look at changing the way we handle whitespace in
bracketed expressions in POSIX mode (POSIX_STRINGS option?  That's
about the closest I can see and underworked at the moment).

The above still needs some work, though, since we don't currently word
split case statements.  I think that probably is required by the
standard since it specifies word (though not word list) handling,
i.e. implying the same as command line words but with an additional "|"
token between words.  That's probably going to have to wait till after
5.0.8.

pws


  reply	other threads:[~2015-05-14 17:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-14 13:14 Martijn Dekker
2015-05-14 13:50 ` [BUG] " Martijn Dekker
2015-05-14 14:42 ` Peter Stephenson
2015-05-14 15:47   ` Martijn Dekker
2015-05-14 15:55     ` Peter Stephenson
2015-05-14 17:30       ` Bart Schaefer
2015-05-15  0:05         ` Chet Ramey
2015-05-14 23:51       ` Chet Ramey
2015-05-15  8:38       ` Peter Stephenson
2015-05-15 20:48         ` Peter Stephenson
2015-05-15 21:48           ` Bart Schaefer
2015-05-14 16:17     ` Peter Stephenson
2015-05-14 17:07       ` Martijn Dekker
2015-05-14 17:43         ` Peter Stephenson [this message]
2015-05-15  0:09           ` Chet Ramey
2015-05-14 23:59       ` Chet Ramey
2015-05-14 21:23   ` Chet Ramey
2015-05-14 23:45   ` Chet Ramey

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=20150514184332.3803584d@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=martijn@inlv.org \
    --cc=zsh-workers@zsh.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.
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).