From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 989 invoked from network); 30 Oct 2022 17:22:46 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 30 Oct 2022 17:22:46 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1667150566; b=HSBW8EinYkG/S/krkPn2BeEzHrXQ4WVY0SKJDfKCiYs/NB65m1cghINriV9sA7wflJJbPVpgl1 xljf23wUzcp8pWpfxt9UW+d+obBLADYwdj+sEtQyQcVM7YB3nXtv4+R+/a2cgyK8f4+VQ5oAUP 8SYQnS66st3i8GT4JeIVxJ+3c9vQuiVirWLeza+x8gTiaJtE2lRPDaQnsTO1gs6VmW/+oUO2hC EEi059+UYWQvg3clFtSi1qglUKxVRR51jDJ0BSI5d4oN2Qu4td6ocHAhdoLzwKPZNMKEtS2iPS 8GBkZajzw5a/BKgrKZKCu23KmDsdI/w0ajXtGSS4XSUuHQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (granite.fifsource.com) smtp.remote-ip=173.255.216.206; dmarc=none header.from=fifi.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1667150566; bh=7MFvKVIiNXb+R5O7+vQ9UtoRtUZR8GNAlKuh9pgwpQQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:MIME-Version:Content-Type:References:In-Reply-To:Date:To: From:Subject:Message-ID:DKIM-Signature; b=P8VkPLN3fB8gKT6hRCOfPFuPLIXG+WEz4jncAI4vio8e9/+EzAUO7+NQx13CqiNkkiTJhVuXA5 l7Ue8SF4MsB8bvAQMSf2MGzUeENh8L2o66KZkcp2W9rCeWbWwnjXYWjR7791WXE4DhMjUoxgzs zcNl7ai+GPysKtdWcRLHhAcvjEL4mKqrOWZMB2VSohlXKYPGc5ST2v2dSpwvChMSTcjgVNtvcT RFaDOLYpDfXXwf9CYvnHt8yE73T3aFV4wTUgJlRzmwZWbBsceawuLmy2eerjyrZZF4qDgcSut4 LJgyjsQ8vwN4/hXmwrlxHTTYlA7xNqrH9UnFG/YKipadbQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:MIME-Version:Content-Type:References: In-Reply-To:Date:To:From:Subject:Message-ID:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=0v8pFK/ml1boU99LiS/9/Ese6bgPso+EIU21C2lUUt4=; b=QzfiIVvKNJwi/iMTPWpq8lYbl1 FCb+qgSE5Nn8UvYONbd4WJQC2jjqjLknwuZEP9wMP3Q466jCDrT5tjSkjMFPWxjifkYvNUX6q8YwV 0xdEhnM9XlzBvJfRfMe5ojB9a+bSb1ZGIjVHJJjPoG6kOr/d/OzrA84oqVlSDqEE+3KarRhgzn8nP rt1wQhXKEcEeQz9v7Rfluji6mPLzy4ojx4Bp9vYIoU7BsxlP/S4Y4QKRziCaQJkF7UBhfnowdD9kp Np63ZOrrNlAekwmFTwXqnCCT0GuBlWRdngwH7SkQ6hKrjVs0msWa/XIOsqI3FZtnpNZod6rmwXDlG ynA6WI1w==; Received: by zero.zsh.org with local id 1opC1E-000D1s-H8; Sun, 30 Oct 2022 17:22:44 +0000 Authentication-Results: zsh.org; iprev=pass (granite.fifsource.com) smtp.remote-ip=173.255.216.206; dmarc=none header.from=fifi.org; arc=none Received: from granite.fifsource.com ([173.255.216.206]:48898) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1opC0L-000CIO-8m; Sun, 30 Oct 2022 17:21:49 +0000 Received: from ceramic.fifi.org (107-142-44-66.lightspeed.sntcca.sbcglobal.net [107.142.44.66]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by granite.fifsource.com (Postfix) with ESMTPSA id 87BFA4076; Sun, 30 Oct 2022 10:21:47 -0700 (PDT) Message-ID: Subject: Re: better grammar with $# From: Philippe Troin To: Ray Andrews , Zsh Users Date: Sun, 30 Oct 2022 10:21:47 -0700 In-Reply-To: References: Content-Type: multipart/alternative; boundary="=-400TGrkhkAzxOPrAL0/I" User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Seq: 28285 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --=-400TGrkhkAzxOPrAL0/I Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, 2022-10-30 at 07:16 -0700, Ray Andrews wrote: >=20 > =C2=A0=C2=A0=C2=A0 output=3D$( eval "$@" )=C2=A0 # Input here is a 'find'= command > outputting a list of files. > =C2=A0=C2=A0=C2=A0 tmp=3D( ${(f)output} )=C2=A0=C2=A0 # Count lines not c= haracters. > =C2=A0=C2=A0=C2=A0 linecount=3D$#tmp > ... it seems clumsy to create 'tmp' just to count lines, can that be > a bit more streamlined?=C2=A0 And is it lines or words there?=C2=A0 The o= utput > is filenames so words=3Dlines in this case but maybe not in other cases > so I'd like to be sure to have a count of lines.=C2=A0 Easy to get one's > splitting wrong. How about: linecount=3D${#${(f)"$(eval "$@")"}} Phil. --=-400TGrkhkAzxOPrAL0/I Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable =20
On Sun, 2022-10-30 at 07:16 -0700, Ray Andrews wrote:


    output=3D$( eval "$@" )&= nbsp; # Input here is a 'find' command outputting a list of files.
&nbs= p;   tmp=3D( ${(f)output} )   # Count lines not charact= ers.
    linecount=3D$#tmp

... it seems clumsy to = create 'tmp' just to count lines, can that be a bit more streamlined? = And is it lines or words there?  The output is filenames so words=3Dl= ines in this case but maybe not in other cases so I'd like to be sure to ha= ve a count of lines.  Easy to get one's splitting wrong.


How about:
lin=
ecount=3D${#${(f)"$(eval "$@")"}}

Phil.

--=-400TGrkhkAzxOPrAL0/I--