From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25944 invoked by alias); 26 Sep 2015 17:57:27 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20647 Received: (qmail 24154 invoked from network); 26 Sep 2015 17:57:26 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 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== MIME-Version: 1.0 X-Received: by 10.140.98.238 with SMTP id o101mr12981123qge.70.1443290243166; Sat, 26 Sep 2015 10:57:23 -0700 (PDT) In-Reply-To: <187221443289280@web15m.yandex.ru> References: <20150926101839.GA14021@gmail.com> <187221443289280@web15m.yandex.ru> Date: Sat, 26 Sep 2015 19:57:23 +0200 Message-ID: Subject: Re: question about parameter expansion From: Mikael Magnusson To: ZyX Cc: Dmitri Vereshchagin , Zsh Users Content-Type: text/plain; charset=UTF-8 On Sat, Sep 26, 2015 at 7:41 PM, ZyX wrote: > 26.09.2015, 16:38, "Mikael Magnusson" : >> On Sat, Sep 26, 2015 at 12:18 PM, Dmitri Vereshchagin >> 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