From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-users@zsh.org
Subject: Re: array matching: inconsistent behaviour ?
Date: Wed, 09 Jan 2013 09:40:54 +0000 [thread overview]
Message-ID: <20130109094054.021cbaa6@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <CACQNQ9Mn8ydkZ5+EckXJ38ywV8iCxyqcBzVCTFSTH4bs6QNLBw@mail.gmail.com>
On Wed, 09 Jan 2013 12:00:34 +0530
rahul <rahul2012@gmail.com> wrote:
> Or am I doing the matching wrong? I am storing file names in an array.
> Later I match filenames against those in the array for various
> purposes. The filenames contain spaces and in this unfortunate case
> round brackets. File names with brackets are failing the match.
>
> FOO=()
> x="a file"
> y="a(file)b"
>
> FOO+=($x)
> FOO+=($y)
>
> print $FOO[(i)$x]
> print $FOO[(i)$y]
>
> # Now I found, that if i quote the string while matching then the
> comma file matches, but now the space file fails.
>
> print $FOO[(i)$x:q]
> print $FOO[(i)$y:q]
You're not exactly doing anything wrong, but quoting here has alwas been
a bit funny to allow (some forms of) pattern matching. To ensure an
exact string match you can use the (e) flag...
% print $FOO[(ie)$x]
1
% print $FOO[(ie)$y]
2
pws
next prev parent reply other threads:[~2013-01-09 9:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-09 6:30 rahul
2013-01-09 9:35 ` Han Pingtian
2013-01-09 10:23 ` rahul
2013-01-09 9:40 ` Peter Stephenson [this message]
2013-01-09 10:33 ` rahul
2013-01-09 15:56 ` Bart Schaefer
2013-01-09 16:53 ` rahul
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=20130109094054.021cbaa6@pwslap01u.europe.root.pri \
--to=p.stephenson@samsung.com \
--cc=zsh-users@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).