Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: question about parameter expansion
- X-seq: zsh-users 20647
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: ZyX <kp-pav@xxxxxxxxx>
- Subject: Re: question about parameter expansion
- Date: Sat, 26 Sep 2015 19:57:23 +0200
- Cc: Dmitri Vereshchagin <dmitri.vereshchagin@xxxxxxxxx>, 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=kyGKX7i4WfrvNs/7gHK/fNueCT6zLVwtp5DIZsQBg5Q=; b=j9Pp0N0sdD6FfHnW7MAFXiHfV1qJgZSjyKrmql4quywgBRdWrko8jUaLlbdBQGVMNl ThklPD+l2EWMW2uCPjhNqCUvjNTiFmcnMQX348kWTb9T926WFT3OXmZlGn7sT88uGySE p2+nY7ueJREg7jAWJSXlSFbzp6ipgNOsAYACEsLShjt2aADJ6KVE9ijszx8qtP5a22EV pTIhiX2a2fr60yBGXnuKWNyTSrZP5NDCD0JyagAUIA028V1zkuVMJeDvRAYHFc3RITyQ 2ypZGnLLXoZFgts54Mxp8YWyDSw2MtJ4fGQV4i8HI074KmXrl/TDZqL04gqXJzDnB/Y/ p+6w==
- In-reply-to: <187221443289280@web15m.yandex.ru>
- 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> <CAHYJk3QegiGeqwiw834TVW+tFzvW5+HKV0cvopDyxOJnrZ6LYQ@mail.gmail.com> <187221443289280@web15m.yandex.ru>
On Sat, Sep 26, 2015 at 7:41 PM, ZyX <kp-pav@xxxxxxxxx> wrote:
> 26.09.2015, 16:38, "Mikael Magnusson" <mikachu@xxxxxxxxx>:
>> 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}
>
> Why not simply
>
> bar=${foo+baz}
>
> ?
The main reason would be that it doesn't do what OP asked for.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author