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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 11C7121818 for ; Sun, 14 Apr 2024 16:48:35 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1713106115; b=gys+pzHhWrj4ls4ojEvErzH1SUW4KeadpbOQ+Eo2ZJQxSluIeRGr5oxFhFL60Za1eAu6f9DRin qXwZW+WsBb/VEsKreRDVuYpYivmvuUpOO1TBPE6ciZhx1558ah/Z9rnv6uh6gOyG9K3jIZCk67 LOl4ZBjH9zK8hFFTQNsTcSCyIM1MEZWSP/RoM+IUZ9/2CCD+t992kZ8OA2s6P7Fb1gUq+87GBu Y1y0uW04PYn2c6ygp454PbHs1lfnwMscf846eJK7X+1ITrqoYEZUoB/vkL+xJCkXt2mBW5z6Y2 LC8OacUhNtZtBTsKGcx2kByQ4PN/uL3/7g59uSOsPwIpgw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta04.eastlink.ca) smtp.remote-ip=24.224.136.10; 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=1713106115; bh=sGDqc0qJY+eVIv0qHHO18q1eFnnGzi2AOAkvwD2HuzQ=; 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=mek0ZQRXvSFzsVNkhk2TnrNJNp1Mg1oarRpdAjS3qcqW98AWMunCIi1CuiZ9VEXeNoqohDa8SD Zz9nKwWgfo1wvvym+HJl9NsMmu5eEFzTCKhqrA9gNQldUTvwrsXrKbgcyVLOH7Xf0LA1NkH+U7 Cj5Bsm7kLpy61fMdrgKIcLl9XqLMfHPvGnagqmnPdIdXl7TKc5Oj89TDFkWlGf/uUNL76qvGZL c2bLcOfcEOWiQowi4+4V6LIJMO3yw4h8zzkB8GN1bsn9Um3Kbig24mM/VwL1Xt05tCncjEB8sP b/f418oSZNs3T7aW5a20nzETOyvGFEWmkGeRlMCKmWAWKw==; 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=g1i6MTaPVYyz9BTdv+tkw7WoDqMbLFIv+uBKzSHEpN8=; b=UwRilXohRgmM2VMNaZi2wc0Wb4 0p01sjfiJpkMg2rBZeRPfVrhwjAhoRfmPOM2K+S8+Fw9QPN1aOl9tkIGwDuVU8QgYmWy0pF+XwDtR zmjD6nT4GPTmwNhKOx1VD52LLc4jeA7wkIKOR4RkKHeoz0MN4qgKncizG9Dd18K7FxY5ccPSFuyfB 7Bfc8ogkyL+qKfxI2Q1n88KQPDlDh7/jJy0cyx4O9SdcheGXOSHggzLWUQpsBEJ/Rd9XPPANjoDHb 0zDYY6W3XUEv7rhP3sX+k4JCOokLLyToFcB4WqymYQOH4OeD3fGhrGGkxfk3OPQJuP1NRYQKr3oRv hlZ85VUw==; Received: by zero.zsh.org with local id 1rw19n-000JCx-Ah; Sun, 14 Apr 2024 14:48:35 +0000 Authentication-Results: zsh.org; iprev=pass (mta04.eastlink.ca) smtp.remote-ip=24.224.136.10; dmarc=none header.from=eastlink.ca; arc=none Received: from mta04.eastlink.ca ([24.224.136.10]:46033) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rw194-000IU7-Eh; Sun, 14 Apr 2024 14:47:51 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta04.eastlink.ca ([24.224.136.10]) with ESMTPS id <0SBX0MADFSZNRRC0@mta04.eastlink.ca> for zsh-users@zsh.org; Sun, 14 Apr 2024 11:47:49 -0300 (ADT) Received: from [192.168.0.11] (host-24-207-19-13.public.eastlink.ca [24.207.19.13]) by csp01.eastlink.ca ([71.7.199.166]) with ESMTPSA id w192rxGkHAimnw193r1ojN (version=TLSv1_2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256); Sun, 14 Apr 2024 11:47:49 -0300 X-Authority-Analysis: v=2.4 cv=Q8Rx4J2a c=1 sm=1 tr=0 ts=661bec95 a=e7T7DzMKK1R988ZCg0wLyw==:117 a=e7T7DzMKK1R988ZCg0wLyw==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=IXyQjHAPjikX1kxa_NwA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=pGLkceISAAAA:8 a=yTZlGyI06skGjGakbRUA:9 a=f9DPvhlUjQyBGZky:21 a=_W_S_7VecoQA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudeiledgkeefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurheptgfkffggfgfuvfhfhfgjsegrtderredtvdejnecuhfhrohhmpeftrgihucetnhgurhgvfihsuceorhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrqeenucggtffrrghtthgvrhhnpefhteethfevgeeuvdelgefgvdevudefueduffdvgfelvddvgfdtieegueeuleeifeenucfkphepvdegrddvtdejrdduledrudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrdduledrudefpdhhvghloheplgduledvrdduieekrddtrdduudgnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepreerpdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Content-type: multipart/alternative; boundary="------------Wo8h5A95g1lFPkd0hxNz3q78" Message-id: <2a3cc24f-f006-4889-aaaa-2715b8b1d7cd@eastlink.ca> Date: Sun, 14 Apr 2024 07:47:48 -0700 MIME-version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: triviality regarding $# counts To: zsh-users@zsh.org References: <97793422-1543-4ba6-b52b-ff93eba03ab1@eastlink.ca> <1e53a3f7-9bdb-45ae-81c7-7d0ec1a6a541@app.fastmail.com> <3cc19e86-e953-4e2f-9e57-30ff84f15fdf@eastlink.ca> <0a0b9ec3-4661-4386-9fbf-b3152a46001e@eastlink.ca> <9416dc0a-3e41-4229-a9e1-239411ab3c17@eastlink.ca> <4a1e027c-a9d8-4306-bf3b-e1282914644c@app.fastmail.com> <4e9aa98c-9b5d-4e22-b7fc-8c50a9af9ada@eastlink.ca> Content-language: en-US From: Ray Andrews In-reply-to: X-Seq: 29823 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. --------------Wo8h5A95g1lFPkd0hxNz3q78 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024-04-14 07:06, Mark J. Reed wrote: > > What? No.  Why do you keep bringing (f) into this? That flag has > nothing to do with copying; in fact it intentionally changes things: > anywhere there used to be a single string containing a newline,you get > two strings instead. % hhh=( "${(@f)iii}" ) % typeset -p hhh; typeset -p iii typeset -a hhh=( 'abc\ndef\nghi' ) typeset iii='abc\ndef\nghi' ... newlines still there.  One element. Besides it worked as I showed. > > But if you drop the f, you do get your Xerox copy: > > % fff=( "${(@)ddd}" ) > ... so far so good with tests.  The (f) seems not to have removed anything -- I was sure it did, yesterday :( -- but that was then. But yours seems to work and it's simpler, more intuitive.  The (f) does not seem to be missed, either.  And to think that just yesterday I thought I had this all sorted. > Would it be nicer if you could just do *fff=$ddd* and not have to > include the parens and quotes and @? Sure. You could even make a case > that it /should /work that way, since we're in Zshland where *$ddd* > expands to the whole array instead of a single element. But that's not > the way assignment works. Though, as I said, if the array has no empty > elements, you can get away with just *fff=($ddd)*. 'IF' ... what I'm wanting is some universal copy that has no gotchas. BTW, just philosophically speaking, the parens are an interesting question.  Whereas I'd say that a copy is a copy is a copy: aaa=$bbb ... so whatever bbb may happen to be, aaa will become the same.  But if aaa is a scalar, should it be promoted 'silently' ?  Seems to me the parens are explicit that aaa will become an array so I like them.  One can never be too clear as to what's happening. cut --------------Wo8h5A95g1lFPkd0hxNz3q78 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

On 2024-04-14 07:06, Mark J. Reed wrote:

What? No.  Why do you keep bringing (f) into this? That flag has nothing to do with copying; in fact it intentionally changes things: anywhere there used to be a single string containing a newline,you get two strings instead.
% hhh=( "${(@f)iii}" )
% typeset -p hhh; typeset -p iii
typeset -a hhh=( 'abc\ndef\nghi' )
typeset iii='abc\ndef\nghi'

... newlines still there.  One element. 


Besides it worked as I showed.

But if you drop the f, you do get your Xerox copy:

% fff=( "${(@)ddd}" )
... so far so good with tests.  The (f) seems not to have removed anything -- I was sure it did, yesterday :( -- but that was then.  But yours seems to work and it's simpler, more intuitive.  The (f) does not seem to be missed, either.  And to think that just yesterday I thought I had this all sorted.

Would it be nicer if you could just do fff=$ddd and not have to include the parens and quotes and @? Sure. You could even make a case that it should work that way, since we're in Zshland where $ddd expands to the whole array instead of a single element. But that's not the way assignment works. Though, as I said, if the array has no empty elements, you can get away with just fff=($ddd).
'IF' ... what I'm wanting is some universal copy that has no gotchas.

BTW, just philosophically speaking, the parens are an interesting question.  Whereas I'd say that a copy is a copy is a copy:

aaa=$bbb

... so whatever bbb may happen to be, aaa will become the same.  But if aaa is a scalar, should it be promoted 'silently' ?  Seems to me the parens are explicit that aaa will become an array so I like them.  One can never be too clear as to what's happening.

cut


--------------Wo8h5A95g1lFPkd0hxNz3q78--