From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 5F1DB26E0B for ; Wed, 14 Feb 2024 17:31:11 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1707928271; b=YoffWoD4zhPktst9k18M3tHvsKYinA0DR/U6iFXkSrouLdNqO6OIqiWHJ9wTylXitSQa2CXulp uckQWMjKDOlyMQph5kQRzSr0UndO5DZ8CBRKkfJQwAnTTOBabIcd/bEw5BdUvrvUP2viGuWnqp mYF7tdWL7Ni18scSm1bBRzZrfGXFFmTeTNPeiTYs/CPIlbevJp8SwsTKzvvKObV27yORtoakw+ /MDvP8z5aWie3Ln23I2MLrBz5cHf9uu28bOJnXKNisTDOFC5O9zXaZRUo9l0rwSTMGVPGVlRTG sWR3GvYmZDQfJT5fbHOXE6NMaVlbzSIHBxu40SUOu9KRhg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta03.eastlink.ca) smtp.remote-ip=24.224.136.9; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1707928271; bh=sKbQxJdOBysfgYYnTiZYWpurYf8JcpW31zO7H6+cf+s=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Content-Type:DKIM-Signature; b=Suft9GEePLEweQI7qK8Gk0XWOAqvl4i0cAus84UF6Swms2pC8YanrR65fu8lgpDWM1b12Lj0S9 Io80K6BDn6qrqcBlw4cdb/n4wk4IxBRnXAfFoQXhzb+G7kqeMsLiCALdMb28Hejz40l/ubXlcg DjXIEn8YPA3q6rNeYVlB3qiMc1bTqeK5OHVPU2dnGCTCrIJl8xdv9Upsv5OOjLlWYGtcYxsx4+ ng3hMyUSG/jNz1FOi6EV4gBBbrKPQkub/OMwb6SBFXr5H+lNAugYRlU1wDis95jNUEYlUsYICo AnR7V4UXqGs9Ujmf6a+p9EEjgngab8FgLjW97MKwFQD16Q==; 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:In-reply-to:From:References:To: Subject:MIME-version:Date:Message-id:Content-type:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=KaAWoicLTCA/zKMU97GJEJ/baeBRSHFS9Sny6VfwYrU=; b=dX1ExICxm0tCIij3NKgoYmclML /wjV25e34JhRr173ktTzQM/KQV2WoAtK6VSaEJx7cV2ROJAWZYeAUbYBaVBNk/X8y9i+t8WnsGWPs SwLDY9pcyskzBJADUSAFJoOENNRvFKBkHlrrREJTha8NrQiz1qVFrfif1+63F8SQaNQmR55SjMBtR m7tRzk/zLISSIp2wIBdf11CEqWIq5ixe5ibF3WF2l4R1HfBSp3Dju2pV/mTmsRran+PvvY9G0wasK xfNFo/aBJd74EO6Ib5QPE7VtgpthWuzg4w/GAoksnIguDAb38OIpu9Hvc2qxV94Ink7MaC1GExMtQ zfRqNAcg==; Received: by zero.zsh.org with local id 1raIAB-0003OY-Lo; Wed, 14 Feb 2024 16:31:11 +0000 Authentication-Results: zsh.org; iprev=pass (mta03.eastlink.ca) smtp.remote-ip=24.224.136.9; dmarc=none header.from=eastlink.ca; arc=none Received: from mta03.eastlink.ca ([24.224.136.9]:58417) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1raI9V-0002jO-Hb; Wed, 14 Feb 2024 16:30:29 +0000 Received: from csp02.eastlink.ca ([71.7.199.167]) by mta03.eastlink.ca ([24.224.136.9]) with ESMTPS id <0S8U1WJVATOLRAF1@mta03.eastlink.ca> for zsh-users@zsh.org; Wed, 14 Feb 2024 12:30:28 -0400 (AST) Received: from [192.168.0.11] (host-24-207-19-13.public.eastlink.ca [24.207.19.13]) by csp02.eastlink.ca ([71.7.199.167]) with ESMTPSA id aI9TrHvHvKZm7aI9UrVboA (version=TLSv1_2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256); Wed, 14 Feb 2024 12:30:28 -0400 X-Authority-Analysis: v=2.4 cv=FZuUx4+6 c=1 sm=1 tr=0 ts=65cceaa4 a=e7T7DzMKK1R988ZCg0wLyw==:117 a=e7T7DzMKK1R988ZCg0wLyw==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=t97kWEHV4Y-IXFek-6gA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=pGLkceISAAAA:8 a=-uVya_wqBsNAlLoUoIMA:9 a=MF6jo9iz7xNlz7Oj:21 a=_W_S_7VecoQA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudejgdeltdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfgtefuvffnkffpmfdpqfgfvfenuceurghilhhouhhtmecufedttdenucgoufhushhpvggtthffohhmrghinhculdegledmnecujfgurheptgfkffggfgfuvfhfhfgjsegrtderredtvdejnecuhfhrohhmpeftrgihucetnhgurhgvfihsuceorhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrqeenucggtffrrghtthgvrhhnpeefhedtiedtfeeugfeludefudejffegfeegheevfeffheeifeekieffleeljefhgfenucffohhmrghinheprghrrhgrhidrhihouhenucfkphepvdegrddvtdejrdduledrudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrdduledrudefpdhhvghloheplgduledvrdduieekrddtrdduudgnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepreerpdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 49 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Content-type: multipart/alternative; boundary="------------pmL4fFsF7bUP6ubQrsn1F0gb" Message-id: <58e3e416-1e9f-424c-b9af-b96b93dc9938@eastlink.ca> Date: Wed, 14 Feb 2024 08:30:27 -0800 MIME-version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Counting characters in command output? Content-language: en-US To: zsh-users@zsh.org References: <0b3cf56b-004d-4a9f-a643-a53ccb50e278@eastlink.ca> From: Ray Andrews In-reply-to: X-Seq: 29671 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: This is a multi-part message in MIME format. --------------pmL4fFsF7bUP6ubQrsn1F0gb Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024-02-14 07:58, Mark J. Reed wrote: > > I myself almost always want lines.  Or elements.  Sometimes words, > almost  never characters. > > As I said, it's the consistency. Right.  That would be second on my list of vectors and should trump tradition, especially when, as Roman says, most users don't prefer the status quo. > If you have a scalar parameter named *foo*, *$#foo* is the number of > characters. If it's an array, *$#foo* is the number of elements.  The > key point in my mind is that when you assign a parameter from command > substitution, e.g. *foo=$(bar)*, then what you get is a scalar > parameter, not an array. You /can/ get an array instead, but you have > to ask for it explicitly by putting extra parentheses around the right > hand side: *foo=($(bar))*. So parameter assignment defaults to scalar > mode and requires extra punctuation to do array mode. But directly > counting the result of the substitution with no intervening parameter > defaults to array mode and requires extra punctuation to do scalar mode. So really there is a logical problem too.  We have another 'invisible' transformation.  We 'have' quarts but liters are what's counted, yes? > I would in general have expected *foo $(bar) * to behave identically to *baz=$(bar); foo $baz*. Yes, it would be non-negotiable in algebra.  a=b; b=c; ergo a=c. --------------pmL4fFsF7bUP6ubQrsn1F0gb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

On 2024-02-14 07:58, Mark J. Reed wrote:
> I myself almost always want lines.  Or elements.  Sometimes words, almost  never characters.

As I said, it's the consistency.
Right.  That would be second on my list of vectors and should trump tradition, especially when, as Roman says, most users don't prefer the status quo.

If you have a scalar parameter named foo, $#foo is the number of characters. If it's an array, $#foo is the number of elements.  The key point in my mind is that when you assign a parameter from command substitution, e.g. foo=$(bar), then what you get is a scalar parameter, not an array. You can get an array instead, but you have to ask for it explicitly by putting extra parentheses around the right hand side: foo=($(bar)). So parameter assignment defaults to scalar mode and requires extra punctuation to do array mode. But directly counting the result of the substitution with no intervening parameter defaults to array mode and requires extra punctuation to do scalar mode.
So really there is a logical problem too.  We have another 'invisible' transformation.  We 'have' quarts but liters are what's counted, yes? 

> I would in general have expected foo $(bar)  to behave identically to baz=$(bar); foo $baz.

Yes, it would be non-negotiable in algebra.  a=b; b=c; ergo a=c.

--------------pmL4fFsF7bUP6ubQrsn1F0gb--