Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
array matching: inconsistent behaviour ?
- X-seq: zsh-users 17543
- From: rahul <rahul2012@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: array matching: inconsistent behaviour ?
- Date: Wed, 9 Jan 2013 12:00:34 +0530
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=cjeZCnlzcuUyWls3Q2Ezdo24CzvKCsncEaej8Q9f7iY=; b=jhozta3IhdZKV4e5CfnIzRaFTE7mscsd7pXSRE0MmMNEKjgzGrGrzWhkaCc+/jw0oo yXR+CB9YCQavgfbO7VJtY5AWnm8i66vSWam8jfOC4FHBGoKRFbcJv45Ff1ICw3VkOlj4 2mc/1GgEc8QzDo1f4AV4l81TCl2KvVypnaeuPdbaE1UmPYv5VL356NCiLXXiQOIfal+z daM/qLNQHUU8cScIRCKS5arvHvEVLpvlZVH9g4sQt/deEDGSc4y4aHNek47GDSyJAyFL bCOlVrVTeVqdg6ywcYCUft/B/R2BKD5IwUXJLbTtbuzhWmXS+nv9bMlXhooqAP0RK7QE CkYQ==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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]
If I escape/quote the string when adding to the array then again one of the
two matches fails. In any case, I cannot escape the names when inserting
into the array, as often double quoting/escaping happens when methods are
called repeatedly, and external commands give errors if they get quoted
filenames. I only quote the string finally if I am "eval"ing a command.
I'd like to know if I am doing this wrong, is there a consistent way of
matching the string inside the array.
--
rahul
Messages sorted by:
Reverse Date,
Date,
Thread,
Author