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 888C521562 for ; Sat, 13 Apr 2024 03:14:06 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1712970846; b=rLZmmg1g1IPwZ39+qkHvVllSOSrMoTJqbFo0rZfvJ5pZZxcFrAhS/Fu/Z4gelcQMNuq+ubggfS Ugf5rwOEAtCUD32w90mFiqN/OSRYKq2qckuPstV0u1Jp4xCqnVt77AY5oreM10X4IS5Uwm3gwA doWE705g3nLMwfP252Eld8JWaycbTyZIdMSLu1z+5Ebq58hxapX1DObjdM0yv365VekJnkPJ8G 0AFc8RvESRr4kOCNkYsPr+MAe4HKPZyHbzv0D2++s59MYUeXZanIhYjwb0Az3uRKSwOvcSiP3y 3aERxtgcPDPGBRrXLpxZ0ed1w4Q12gIVaoJFu0SDnjnjIg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta02.eastlink.ca) smtp.remote-ip=24.224.136.13; 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=1712970846; bh=jMOMIcrOANDZUvlz88Df3u5nOgqXnVy7bM1hQYVNiLg=; 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=R2vkRDhy/v4uTVVGjNcIb0Ept4YOdSLU5+KdX5nFjLjvpUvnnQJ4dVpstitJKPJTo++9UeUyHt j1SlQ1E3nSYfSr4Dj2KoV6WlHguWcKa3/s+tuk6sZrAIW67iUqbNQouqQG/YOBUOP9CPKVO558 ZnFO7qLTR87uQfco/pbPci/BlESYBnh9SY2TQx+b0PIjZjeHU8Ps12MHo1MLF0vfCVAbCFH4BB HpoQkUxGuFNIFSn1e4g+2+kzV57+wS+kFK5qa1CTJCRdpjI84qJnIQ1dB7us6eKaKCXqWLZCnN DjlqYk03Jg5za0M+UpJE5gMV3MvZB/7i8iBoO4N5VAtrrQ==; 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=nU1f2cmw/asXC2VOYrv9sBpeDU1C0sxrxeEplCQFK7I=; b=oLZ2xaf9EY3V7zEe7gylU67Qph g3fCdrQM24vHT2JTNn/o7uIrZrm5T6l7h+9ufajv+luo9UcpsCzx1E/upmUVCg0JWJ8y/I8Q7VGsW HUSydESO043/0vSXFKuFVzzhqa5pKxS7l/et1ZRkeFkglX5V5Bd8D9BrA4OxM/RnS+Gj35Zv8mFaD SDcycYKKHSwTnJSRhMjbvHwTnYRSSrKROXqS3AAhHbEpaiL3rWSax3Q1boS+CYVpPRM8oKT8j/M8X IuPVl7OTHZnQS0ValkTI/UFQi1pJul5SxCAtyoOTtuhpoSgjSk3bmobjXhVfjt+Hcb9hWnJdH99RH 4iuL5tvg==; Received: by zero.zsh.org with local id 1rvRy1-000ARJ-6p; Sat, 13 Apr 2024 01:14:05 +0000 Authentication-Results: zsh.org; iprev=pass (mta02.eastlink.ca) smtp.remote-ip=24.224.136.13; dmarc=none header.from=eastlink.ca; arc=none Received: from mta02.eastlink.ca ([24.224.136.13]:40497) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rvRxI-0009jl-1B; Sat, 13 Apr 2024 01:13:21 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta02.eastlink.ca ([24.224.136.13]) with ESMTPS id <0SBU097HXWPI64U0@mta02.eastlink.ca> for zsh-users@zsh.org; Fri, 12 Apr 2024 22:13:18 -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 vRxFrsKqQAimnvRxGr17P4 (version=TLSv1_2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256); Fri, 12 Apr 2024 22:13:18 -0300 X-Authority-Analysis: v=2.4 cv=Q8Rx4J2a c=1 sm=1 tr=0 ts=6619dc2e a=e7T7DzMKK1R988ZCg0wLyw==:117 a=e7T7DzMKK1R988ZCg0wLyw==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=L4ssB7qIRFB5oD0HB6wA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=pGLkceISAAAA:8 a=qRIZaQElwZcRpvDRUWoA:9 a=Pi9cMEBjymHqO-kt:21 a=_W_S_7VecoQA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudeihedgtdehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurheptgfkffggfgfuvfhfhfgjsegrtderredtvdejnecuhfhrohhmpeftrgihucetnhgurhgvfihsuceorhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrqeenucggtffrrghtthgvrhhnpefhteethfevgeeuvdelgefgvdevudefueduffdvgfelvddvgfdtieegueeuleeifeenucfkphepvdegrddvtdejrdduledrudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrdduledrudefpdhhvghloheplgduledvrdduieekrddtrdduudgnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepreerpdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Content-type: multipart/alternative; boundary="------------Wb5XzraezvREuoJe0jWh7NB9" Message-id: <7ba17739-6024-439b-a4a7-dd88fddfa2e4@eastlink.ca> Date: Fri, 12 Apr 2024 18:13:17 -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> Content-language: en-US From: Ray Andrews In-reply-to: X-Seq: 29797 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. --------------Wb5XzraezvREuoJe0jWh7NB9 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024-04-12 12:09, Bart Schaefer wrote: > None of that is about $#. $# just counts either characters in a > string or elements in an array, full stop. Right, it's a question of getting the splitting correct. > What you're asking for is a dissertation on how to split text into > arrays. I have no idea what you mean by "without spaces" and there's > no inherent definition of a "paragraph" I know it, thus the air-quotes, In one of my tests I had three consecutive outputs from aptitude written to the array and at some point the count was 3, so somehow each separate output got merged into one element. > so the best you could get from > this is characters, words, and lines -- but even for words you need to > explain whether you mean "shell words" (separated by $IFS characters) > or something else, including whether quotes matter. It is a bit confusing. > Further, you seem > to be starting from scalar text sometimes, and text that's already > split into an array other times -- in the latter case you have to > explain whether and how you want the array re-joined into a block of > text before re-splitting. I've got a whole bunch of that figured out today.  What I thought were arrays were scalars that just happened to print nicely on separate lines where wanted but not due to '\n''s.  And what I thought line splitting -- (f) -- did was enter '\n's into the body of the variable -- a guy might be forgiven for thinking that -- but no it's dollar signs.  And efforts to force '\n's' were disastrous. Some quality time with typedef -p really helped.  Sorta funny, everything was working fine, but there were hidden disasters lurking that surfaced for that most trivial of reasons -- but forced me to redo quite a bit of stuff where things really are arrays and nevermind the '\n's.  And I get my line counts honestly now :-)  One thing: it sure is hard to hang on to blank lines.  I wish there was some option to default to preserving them. > The shell is not a word processor and doesn't understand your > conceptualization of text formatting. Very true.  But I focus on what I can see and if it looks right it's easy to think it is right.  Anyway, thanks to Lawrence much as been learned. BTW $# is a very convenient way of detecting how things are split, now that I know that scalars always return character counts and arrays, element counts.  Easy! --------------Wb5XzraezvREuoJe0jWh7NB9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 2024-04-12 12:09, Bart Schaefer wrote:
None of that is about $#. $# just counts either characters in a
string or elements in an array, full stop.
Right, it's a question of getting the splitting correct. 
What you're asking for is a dissertation on how to split text into
arrays.  I have no idea what you mean by "without spaces" and there's
no inherent definition of a "paragraph" 
I know it, thus the air-quotes, In one of my tests I had three consecutive outputs from aptitude written to the array and at some point the count was 3, so somehow each separate output got merged into one element. 
so the best you could get from
this is characters, words, and lines -- but even for words you need to
explain whether you mean "shell words" (separated by $IFS characters)
or something else, including whether quotes matter.
It is a bit confusing. 

  Further, you seem
to be starting from scalar text sometimes, and text that's already
split into an array other times -- in the latter case you have to
explain whether and how you want the array re-joined into a block of
text before re-splitting.
I've got a whole bunch of that figured out today.  What I thought were arrays were scalars that just happened to print nicely on separate lines where wanted but not due to '\n''s.  And what I thought line splitting -- (f) -- did was enter '\n's into the body of the variable -- a guy might be forgiven for thinking that -- but no it's dollar signs.  And efforts to force '\n's' were disastrous.  Some quality time with typedef -p really helped.  Sorta funny, everything was working fine, but there were hidden disasters lurking that surfaced for that most trivial of reasons -- but forced me to redo quite a bit of stuff where things really are arrays and nevermind the '\n's.  And I get my line counts honestly now :-)  One thing: it sure is hard to hang on to blank lines.  I wish there was some option to default to preserving them.
The shell is not a word processor and doesn't understand your
conceptualization of text formatting.
Very true.  But I focus on what I can see and if it looks right it's easy to think it is right.  Anyway, thanks to Lawrence much as been learned. BTW $# is a very convenient way of detecting how things are split, now that I know that scalars always return character counts and arrays, element counts.  Easy!

--------------Wb5XzraezvREuoJe0jWh7NB9--