From: "Lawrence Velázquez" <larryv@zsh.org>
To: zsh-users@zsh.org
Subject: Re: CONDITIONAL EXPRESSIONS, string == pattern
Date: Sat, 24 Jul 2021 23:48:44 -0400 [thread overview]
Message-ID: <6A60A149-8728-4140-ADBA-AC67ABDD3BF6@zsh.org> (raw)
In-Reply-To: <45ef93bd-148b-54fc-9815-5b5dbe71d1f0@gmx.com>
> On Jul 24, 2021, at 11:30 PM, Eric Cook <llua@gmx.com> wrote:
>
> so in:
>
> eval echo 'test ${vs} == ${vp} && echo hi || echo lo'
>
> zsh does the normal expansions of the line and passes the arguments to eval, since the single quotes prevented
> any possible expansions the result is:
>
> echo test ${vs} == ${vp} && echo hi || echo lo
>
> so the above line goes through the steps of expansions and ends up like so:
>
> echo test ' str1 a2' '==' '[[:blank:]]##str1[[:blank:]]##[[:alnum:]][[:alnum:]]' && echo hi || echo lo
>
> so /echo/ prints out the strings given to it, which succeeds, causing echo hi to run.
I'll just add that examining the full contents of 'r' would have
provided a big hint that 'test' wasn't being run at all.
% cat /tmp/testing2.zsh
setopt EXTENDED_GLOB NO_EQUALS
vs=' str1 a2'
vp='[[:blank:]]##str1[[:blank:]]##[[:alnum:]][[:alnum:]]'
r=( ${(f)"$( eval echo 'test ${vs} == ${vp} && echo hi || echo lo' )"} )
typeset -p r
% zsh -f /tmp/testing2.zsh
typeset -a r=( 'test str1 a2 == [[:blank:]]##str1[[:blank:]]##[[:alnum:]][[:alnum:]]' hi )
--
vq
prev parent reply other threads:[~2021-07-25 3:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-25 2:14 scowles
2021-07-25 3:30 ` Eric Cook
2021-07-25 3:48 ` Lawrence Velázquez [this message]
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=6A60A149-8728-4140-ADBA-AC67ABDD3BF6@zsh.org \
--to=larryv@zsh.org \
--cc=zsh-users@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).