From: scowles@ckhb.org
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: using dynamic patterns on the left hand side of case statement clauses
Date: Wed, 18 Mar 2020 16:54:27 -0700 (PDT) [thread overview]
Message-ID: <alpine.DEB.2.21.2003181539320.8081@ckhb02> (raw)
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?
next reply other threads:[~2020-03-18 23:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-18 23:54 scowles [this message]
2020-03-19 1:29 ` Lawrence Velázquez
2020-03-19 4:38 ` Phil Pennock
2020-03-19 5:25 ` Lawrence Velázquez
2020-03-19 17:47 ` scowles
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=alpine.DEB.2.21.2003181539320.8081@ckhb02 \
--to=scowles@ckhb.org \
--cc=zsh-workers@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).