zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: 'case' pattern matching bug with bracket expressions
Date: Thu, 14 May 2015 10:30:03 -0700	[thread overview]
Message-ID: <150514103003.ZM30746@torch.brasslantern.com> (raw)
In-Reply-To: <20150514165557.59f6bdc9@pwslap01u.europe.root.pri>

On May 14,  4:55pm, Peter Stephenson wrote:
}
} It occurs to me that other shells will treat whitespace as ending a
} pattern for syntactic reasons, even if logically it can't:
} 
} [[ ' ' = [ ] ]]
} 
} works in zsh, but is a parse error in bash.

Right, and your patch in 35131 does not change that.  Arguably (in POSIX
mode, at least) the space should need to be escaped?

Even in bash the space can be left unescaped in some contexts; e.g.

schaefer@burner:~$ var=' '
schaefer@burner:~$ echo ${var//[ ]/foo}
foo

I guess it's a quoting thing:

schaefer@burner:~$ case " " in ( [" "] ) echo OK;; esac
OK

In ${...} the space is already implicitly quoted, but quoting it again
doesn't change anything:

schaefer@burner:~$ echo ${var//[" "]/foo}
foo
schaefer@burner:~$ var='"'
schaefer@burner:~$ echo ${var//[" "]/foo}
"

Anyway, this is one of the rare cases where I don't think it would be
terrible if this changed in native zsh mode too, as long as the quoted
examples, like the above, don't break.

-- 
Barton E. Schaefer


  reply	other threads:[~2015-05-14 17:30 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 [this message]
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
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=150514103003.ZM30746@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --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).