Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: question about parameter expansion
- X-seq: zsh-users 20644
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Dmitri Vereshchagin <dmitri.vereshchagin@xxxxxxxxx>
- Subject: Re: question about parameter expansion
- Date: Sat, 26 Sep 2015 15:37:15 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=YgpAj5UHMPZBzjCFHojAK8GEyxE/PxfSN5oy8atvJ8M=; b=kTqMjeqH/KjoqElNpOZoguRS5PBEqB/9bVq21gu1Hk6tTYeucc9vB8Bxvz7GSJR34D 9bgYzU7TokuCKdpwhal96tso/WRp+MYvshL0WDoIlaJwgkjcNjaHHMZd71J0//gJ2ChF +FprJ3cj2nnNqicIZHzIcMFhnO8Nolc7sXkkFioMMb3w84nj+h3OvF808AnPSckjywGj p/Y5NvP6h6GnA7iJ2dscyaoS1DYvEX3xS9oYfjmnD4AIw0ueUg4GN8rxP/zNOxcWDXZ3 N1S/jnO3FG59zEYjt/KkWSTYBTWhX0jCFZpkfok2FZ4wddXbu6DPdhLLnaJ2V/TVYosi cUxg==
- In-reply-to: <20150926101839.GA14021@gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20150926101839.GA14021@gmail.com>
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