Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Array index
- X-seq: zsh-workers 3595
- From: Bernd Eggink <eggink@xxxxxxxxxxxxxxxxxx>
- To: Zsh-workers <zsh-workers@xxxxxxxxxxxxxxx>
- Subject: Array index
- Date: Mon, 03 Nov 1997 09:27:04 +0100
- Organization: Regionales Rechenzentrum der Uni Hamburg
- Sender: rz2a022@xxxxxxxxxxxxxxxxxx
What is the easiest way to find the index of a specific element in an
array, apart from using a for loop? The statement
(( i = array[(i)$value] ))
fails if $value contains special characters like parentheses. I tried
quotes on different parts of the expression, but without success.
Example:
x='a(b)'
arr=($x bla)
print $arr[(i)$x] # 3
print $arr[(i)"$x"] # 3
print $arr["(i)$x"] # zsh: bad math expression: unbalanced stack
Any ideas?
Bernd
--
Bernd Eggink
Regionales Rechenzentrum der Universitaet Hamburg
eggink@xxxxxxxxxxxxxxxxxx
http://www.rrz.uni-hamburg.de/eggink/BEggink.html
Messages sorted by:
Reverse Date,
Date,
Thread,
Author