From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26250 invoked by alias); 3 Dec 2017 09:18:37 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42071 Received: (qmail 29690 invoked by uid 1010); 3 Dec 2017 09:18:37 -0000 X-Qmail-Scanner-Diagnostics: from aok120.rev.netart.pl by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(85.128.245.120):SA:0(-1.9/5.0):. Processed in 11.573035 secs); 03 Dec 2017 09:18:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: psprint@zdharma.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Virus-Scanned: by amavisd-new using ClamAV (16) Date: Sun, 3 Dec 2017 10:11:10 +0100 From: Sebastian Gniazdowski To: Bart Schaefer Cc: "=?utf-8?Q?zsh-workers=40zsh.org?=" Message-ID: In-Reply-To: References: Subject: Ternary expression in Zsh (was: Feature request =?utf-8?Q?=E2=80=93_?=substitutions similar to +, -, :+, :-) X-Mailer: Airmail (442) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 25 Nov 2017 at 12:15:42, Sebastian Gniazdowski (psprint=40zdharma.org)= wrote: > if (VAR) =7B return =22=22 =7D else =7B return =22something else=22 =7D= Kept the main point of previous messages. New point =E2=80=93 it is actua= lly possible to have ternary expression in Zsh: % var=3Dabc % echo =24=7B=24=7B=24=7B(M)var=23abc(=23e)=7D:+ternary1=7D:-ternary2=7D ternary1 % var=3Dabcd % echo =24=7B=24=7B=24=7B(M)var=23abc(=23e)=7D:+ternary1=7D:-ternary2=7D ternary2 It's a one-liner =22If val is xyz, then substitute=22. Pretty neat thing,= maybe there are similar tricks possible=3F I have to implement something= and cannot fiddle with this now. -- =20 Sebastian Gniazdowski psprint /at/ zdharma.org