Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
using dynamic patterns on the left hand side of case statement clauses
- X-seq: zsh-workers 45577
- From: scowles@xxxxxxxx
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: using dynamic patterns on the left hand side of case statement clauses
- Date: Wed, 18 Mar 2020 16:54:27 -0700 (PDT)
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Reply-to: scowles@xxxxxxxx
i would like to use dynamic patterns on the left hand side of clauses in case
statements.
i'm working in zsh current as of 3.1-91-g7595b22e on ubu 19.10.
the options set for this example are:
setopt extended_glob
setopt glob
setopt no_no_match
setopt no_null_glob
the code is:
typeset -a a b c
a=( one two three four )
b=( 16 17 18 19 20 )
c=( two 20 )
vb=$'|'
for d in ${c}
do
case ${d} in
$( eval echo ${(j:${vb}:)a} ) ) echo "1 found it" ;;
$( eval echo ${(j:${vb}:)b} ) ) echo "2 found it" ;;
* ) echo "did not find it" ;;
esac
done
but, when i run the code, the interpreter escapes all the vbars and forces the
entire lhs pattern to be a string.
does the case structure not allow this use case? or am i just missing something
from not reading docs carefully enough?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author