Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: question about parameter expansion



On Sat, Sep 26, 2015 at 12:18 PM, Dmitri Vereshchagin
<dmitri.vereshchagin@xxxxxxxxx> wrote:
> Hello.
>
> Here is a code sample I would like to rewrite using parameter expansion
>
>   if (( ${+foo} )); then
>     bar=
>   else
>     bar=baz
>   fi
>
> Cannot find it in the docs, but I suppose there is a way to do that.  Am
> I right?
>
> Thanks.
>
> --
> Dmitri Vereshchagin

You have to think outside the box for this one,
bar=${${${+foo}#1}//0/baz}

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author