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_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 CEE0B21836 for ; Sat, 13 Apr 2024 03:33:55 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1712972035; b=VniaCjlsJCKho7Vw+epHLaqjzxvY3hNnp7Nu+pXGK29sMfbJFW8f8V5hd96pfw2HNkLdEAbCis 4whp9iVMQNCTP50rOLB9g04GSS5WBZ2dbGTukyZEE8EeP6aKq8Dcyg6kuftJxwm+rNM9+mDIGy dr/7NbAIAN9mD5W/LhSMeJ+PQViJ56ABbl7JATMKI4B0adc3n8hZexfvv4LTjZIrm+XRWRNZy+ iaVtT56IiISSnRVdsLeh/3rtZgBmiVfqWs+qh8Q6d6Nkpiwf5KNhQk2Bu0jPjCy4NqbjaW/mQt MOMr442nzwydcJlPol/2y4pzrha28tKbOZvahG+AumsJ+Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f171.google.com) smtp.remote-ip=209.85.208.171; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1712972035; bh=g6RRLuIia90XE2IywzG9WQP+3MmqhSIzb/Gs96OHvxE=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=rhfG7wP/2ZB2ZCiR/1kHqlYP+JBpnDDMnmyt2HjckzS9UtP/ikry8hoWiCDsgKjobxWSKknYif fmjcuZDQsbRsOcc5Gfq92oPPYocQ1cs/TZ+2hcXWnd3UIUrlZDPN2soN58V75H9vKPQKBGOIyF i57x6JQe688nMBpxC3xHztt8A3yT0IklEPz2yubYyr1z7p4aKqDB0fBzpZwIsKG9HHbOw+ChJz CNDoPE9MXO1Ik8eA5MRSV6Vo1bhJuIrzFxa9zVgsKcQ1xSHSNFaaGE2Ul2TnyPIrgkTOGv+ZzM fOaRCHAc14pjjkt0rK2aeX/PRM2whbaEBpa+EsW7rGWpIw==; 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:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=yfuUmotljvoJxCi8F5MBbiq7WnUvG8oKsy8ob8FlWEE=; b=nqSloJtuRYUc9swBNESjbOHSWO HXH4gy1rXKrVvzWy0yoKYbx1dMMFHRsJK29Hoyeo4TxUukZYUgZCdIkG9PUUP6rvph3xBhP1SSZ6f n7ijsLkGazikwaP5wmzLoPCHZaKGOrp1jzCha+qZtCb+F5Hlc07BMmj2BQZPTPJT/tJURbW80QnCD hcPxCqOxGDa8QliJZTxqRRTfdPgnJ47V9kF4fwjjMs7cwwjzfWOby4RH8y/saq72wm41dpt9gvBZX rrycpMv9PsE2fDgcPnac/0HM9i4+Lf2I/WrbXlONxreVSYXlBMnTA0PAewIrNDXqJdWfzRlUySwMY s9La6ltw==; Received: by zero.zsh.org with local id 1rvSHC-000C2H-Gc; Sat, 13 Apr 2024 01:33:54 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f171.google.com) smtp.remote-ip=209.85.208.171; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f171.google.com ([209.85.208.171]:48331) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rvSGb-000BJY-5j; Sat, 13 Apr 2024 01:33:18 +0000 Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2d48d75ab70so21341641fa.0 for ; Fri, 12 Apr 2024 18:33:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712971995; x=1713576795; darn=zsh.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=yfuUmotljvoJxCi8F5MBbiq7WnUvG8oKsy8ob8FlWEE=; b=dkIvdLj0dm7WPiedYVRezvjG83femEkon9tEPko05RNiDzvor1E6/vOi+Diy0twWFF uNRAO9GseOh7SBKTud9bUxVD9JzJN8j01P33YQNQNPWJQZr3wcqU407YrhoTsaMhJSdd zmCbxLAFEpfAJAFLw97OGdVPX5p9/GlFHW1e4BHNeAlc7TtYBGksDb6bX6L22huzwe5L czeDSSrsfwjC/HIPPqO7586kuKkqYnRz9N6lgh/wfUbVb7+8oNAbuXVoWODdhaLAT6Pc rzJhuRLmc1B5IpQTOEQlHuLi+0y1Ecwin0bnXSDLsDalAbil8+q+twsN+53qRh5gFqL8 yixg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712971995; x=1713576795; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yfuUmotljvoJxCi8F5MBbiq7WnUvG8oKsy8ob8FlWEE=; b=sa8ZHV2xTNTJgFrKbf+Gy/axTE3MAQHLgIaqxWqyN7vu+Uazj1jIdA43t/QgLX8ixh UeEMRJt6igudhy6Pl6JAr25CK/53Zuvb8GP4hk10bBDqQ/5fLRJKmXyEUksXfea7nsXt wV8Tk7IoM6wT2WBysaF11srdc69mYVZrfjig1b/7wmWQIQS5L4ZaPuhUCFwG2JdugxtQ 8NEWij88PnU4sa7EGObeFRtpP2wojPFbUrVzOzR0XwQyVX7eNpRzMD297iq7wpsIqR8C rWx3cgaM9ok5ufI5xNs6TY0kemIQqRAGSAFEzZSvNk5/CwmWozEk7VMqoxE+jYa9+NJs vmLw== X-Gm-Message-State: AOJu0YyhqdRp0sbHhrDeJWm38l1JbCdHqPFiS8hXJ0/GuHU5n/j9euxe mso2TTfPCT4fiqaasAb4YjpVrmWr08jcYDnJtIHJqPKERGPzuW8umaCHJ4jbISqgep//Ij06kGq to4d6gCNfdBZMZzAG929H0zu6S1LH+0Dt X-Google-Smtp-Source: AGHT+IGMc8PI52BenD7DU4PDkee5cmfKvrp4qxLnhll1v0hOi+HowucNe8VrY9wkW0Wils+PAhdjVDmQeUCdSZFx7sY= X-Received: by 2002:a2e:a717:0:b0:2d6:c94d:94a2 with SMTP id s23-20020a2ea717000000b002d6c94d94a2mr2335015lje.1.1712971995107; Fri, 12 Apr 2024 18:33:15 -0700 (PDT) MIME-Version: 1.0 References: <97793422-1543-4ba6-b52b-ff93eba03ab1@eastlink.ca> <7ba17739-6024-439b-a4a7-dd88fddfa2e4@eastlink.ca> In-Reply-To: <7ba17739-6024-439b-a4a7-dd88fddfa2e4@eastlink.ca> From: "Mark J. Reed" Date: Fri, 12 Apr 2024 21:33:02 -0400 Message-ID: Subject: Re: triviality regarding $# counts To: Zsh Users Content-Type: multipart/alternative; boundary="000000000000475bf80615f05f7d" X-Seq: 29798 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: --000000000000475bf80615f05f7d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable More context would clarify what you're trying to do and how best to do it. Without that context, the approach you're currently taking feels deeply weird. Can you not provide sample input and desired output? Maybe with all of your code rather than a few snippets from "so deep they need eval", whatever that means... On Fri, Apr 12, 2024 at 9:13=E2=80=AFPM Ray Andrews wrote: > > 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 consecutiv= e > outputs from aptitude written to the array and at some point the count wa= s > 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 b= e > 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 thin= g: > 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. B= TW > $# 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! > > --=20 Mark J. Reed --000000000000475bf80615f05f7d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
More context would clarify what you're trying to do an= d how best to do it. Without that context, the=C2=A0approach you're cur= rently taking feels deeply weird. Can you not provide sample input and desi= red output? Maybe with all of your code rather than a few snippets from &qu= ot;so deep they need eval", whatever that means...

On Fri, Apr 12, 2024= at 9:13=E2=80=AFPM Ray Andrews <rayandrews@eastlink.ca> wrote:
=20 =20 =20

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.=C2=A0
What you're asking for is a dissertation on how to split tex=
t into
arrays.  I have no idea what you mean by "without spaces" and the=
re'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.=C2=A0
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 charact=
ers)
or something else, including whether quotes matter.
It is a bit confusing.=C2=A0

  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.=C2=A0 What I thou= ght were arrays were scalars that just happened to print nicely on separate lines where wanted but not due to '\n''s.=C2=A0 An= d what I thought line splitting -- (f) -- did was enter '\n's into the b= ody of the variable -- a guy might be forgiven for thinking that -- but no it's dollar signs.=C2=A0 And efforts to force '\n's'= were disastrous.=C2=A0 Some quality time with typedef -p really helped.=C2=A0 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.=C2=A0 And I get my line counts honestly no= w :-)=C2=A0 One thing: it sure is hard to hang on to blank lines.=C2=A0 I wish there wa= s some option to default to preserving them.
The shell is not a word processor and doesn't understand you=
r
conceptualization of text formatting.
Very true.=C2=A0 But I focus on what I can see and if it looks right it= 's easy to think it is right.=C2=A0 Anyway, thanks to Lawrence much as bee= n 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.=C2=A0 Easy!



--
Ma= rk J. Reed <mar= kjreed@gmail.com>
--000000000000475bf80615f05f7d--