From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2044 invoked by alias); 26 Sep 2015 13:37:18 -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: 20644 Received: (qmail 3571 invoked from network); 26 Sep 2015 13:37:17 -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=YgpAj5UHMPZBzjCFHojAK8GEyxE/PxfSN5oy8atvJ8M=; b=kTqMjeqH/KjoqElNpOZoguRS5PBEqB/9bVq21gu1Hk6tTYeucc9vB8Bxvz7GSJR34D 9bgYzU7TokuCKdpwhal96tso/WRp+MYvshL0WDoIlaJwgkjcNjaHHMZd71J0//gJ2ChF +FprJ3cj2nnNqicIZHzIcMFhnO8Nolc7sXkkFioMMb3w84nj+h3OvF808AnPSckjywGj p/Y5NvP6h6GnA7iJ2dscyaoS1DYvEX3xS9oYfjmnD4AIw0ueUg4GN8rxP/zNOxcWDXZ3 N1S/jnO3FG59zEYjt/KkWSTYBTWhX0jCFZpkfok2FZ4wddXbu6DPdhLLnaJ2V/TVYosi cUxg== MIME-Version: 1.0 X-Received: by 10.140.145.145 with SMTP id 139mr12609383qhr.100.1443274635196; Sat, 26 Sep 2015 06:37:15 -0700 (PDT) In-Reply-To: <20150926101839.GA14021@gmail.com> References: <20150926101839.GA14021@gmail.com> Date: Sat, 26 Sep 2015 15:37:15 +0200 Message-ID: Subject: Re: question about parameter expansion From: Mikael Magnusson To: Dmitri Vereshchagin Cc: Zsh Users Content-Type: text/plain; charset=UTF-8 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} -- Mikael Magnusson