Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Feature request? print -e to eval ?
On Tue, 5 Sep 2017 13:17:14 +0000
Marc Chantreux <khatar@xxxxxxxxx> wrote:
> i don't know about you but i often eval something i just printed.
> for exemple:
>
> status_as_flag () { eval $( print -P "${1?flag name}=%(?.true.false)" ) }
>
> when it would be nice to write
>
> status_as_flag () { print -eP "${1?flag name}=%(?.true.false)" }
>
> (no more subshell and more readable)
>
> what to you think about the idea ?
Have a look at the (%) flag to ${...}. For example,
${(%):-'blah blah'}
substitues blah blah expanded as a prompt. You can assign that and
print it.
In general, assigning a value then printing it and evaluating
it if you need is probably the way to go.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author