From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19334 invoked by alias); 15 Sep 2015 21:43:54 -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: 20567 Received: (qmail 3977 invoked from network); 15 Sep 2015 21:43:51 -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,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=hHf5pvUC4WiFgQ9s IeZ7WgKgKMY=; b=JGyallKwzqQJNtucFEQSR4VD2ph6NJPkF9o0xArUzJOYcqUb fnCiyrK45nU72Dc+JmPaPyXWRcfbLZJ5fo8jtyKtFAa2o0sOASB5/IoPQKvXyHMV AfTK0+OR8Y3cCmLc4RWVhk1b7NJ+QDn4vnN2ieWYaP0gMBxqPlZ3z9Rm9ZA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=hHf5pvUC4WiFgQ9 sIeZ7WgKgKMY=; b=d2KBoDqeRFtgjSU7AAMwOYzHzOkIE0oUW6+l57rHYechWIr hLDxh2bolFzu4Edk67ZhcAxqubELyaf16x2gFi2/Ngk8A324SC8So9MFnnKhduMd P0PYvnfzAY4rG5QiwTeQTSLVhEHXYy8jrU/zhWdF1PaMMSqgidBJ2P8Ln3s4= X-Sasl-enc: bts3dCMv2WnLIXCn9p+M3Msj7oVLOyqt3HWm8rFcOo81 1442353424 Date: Tue, 15 Sep 2015 21:43:42 +0000 From: Daniel Shahaf To: Jesper =?iso-8859-1?Q?Nyg=E5rds?= Cc: Zsh Users Subject: Re: Number of non-empty elements Message-ID: <20150915214342.GD5696@tarsus.local2> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Jesper Nygårds wrote on Tue, Sep 15, 2015 at 19:15:01 +0200: > I have a fairly long function where the result is stored in an array called > "mylines". > > I want the function to return normally (status zero) if "mylines" contains > at least one non-empty element, and with non-zero otherwise. return $(( $mylines[(I)?*] > 0 )0 The (I) modifier interprets the key as a pattern and returns the highest index of a match, or 0 if there was no match.