zsh-users
 help / color / mirror / code / Atom feed
* array matching: inconsistent behaviour ?
@ 2013-01-09  6:30 rahul
  2013-01-09  9:35 ` Han Pingtian
  2013-01-09  9:40 ` Peter Stephenson
  0 siblings, 2 replies; 7+ messages in thread
From: rahul @ 2013-01-09  6:30 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1005 bytes --]

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-01-09 17:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-09  6:30 array matching: inconsistent behaviour ? rahul
2013-01-09  9:35 ` Han Pingtian
2013-01-09 10:23   ` rahul
2013-01-09  9:40 ` Peter Stephenson
2013-01-09 10:33   ` rahul
2013-01-09 15:56     ` Bart Schaefer
2013-01-09 16:53       ` rahul

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).