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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 29048 invoked from network); 13 Jan 2024 03:07:22 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 Jan 2024 03:07:22 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1705115243; b=UsF1vctPBNjVEfNdbisgkkfusxjeKefnpEn/889H4OLDyB3PQivyryXiDvtKZ9tN3mcspfwI5o Rm0HPci8O8986leUNQqFpxpaRddPPMuCGIiVBuEqEUNH4lFw3df3AD/p0J4ir4L+gieInd6k8j K3PHWZOCvbbvd1b+OfNg0gqlf7bNAruzMZ2SFJjDJMcAQe3nK0Pv4lZwEVZSUp4JbGYrLH/0wb 4KKg9VcKep84xhXA+qCYxbfWbi0WaUReXMNneLN8lV1tSCeCrxfbUmiCtxuG7KBzr5QHXXqWM3 NLpCRsdBV0i7k49uIT+KenmhCbpdx2GeK/LfwKUAkS5asw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta01.eastlink.ca) smtp.remote-ip=24.224.136.30; 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=1705115243; bh=vfu2u8e/Z2Bv6OhRzAm3y6BXjiSnuRmFDXYaf5JwV2U=; 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=qaImhBOO9zVyO8rX8XNTdQnsQJrURWRcPU0XKOUs7eCGzPnfBSc5a6Ny+0Vqbzn/MZ0jMYdgve FhpHfJPOqBE1EQHh/KwPe/iRD+zW2Xpg1d1Wnl11zGvWHioarOo/fawf2eL23rOdu26sCrPDpX wG1zAJlzztNx0jqNigjAEB14g9VXFnufhQKLu0q1gh83O2GZfOcZbbLiUzIWH5zBNIFkK1cquK liYE7Bx7dYd6kv1qB6IoJ7LuzIpUNTLb3UZzbiAz95Ln5nIeCWzV5mNU7PqXPVlX9VlkH3zdeQ LkKzhDTe59Q92sxfKF2oe+VZrq3YOLvgtDyfJ4IOabpELA==; 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=7vnirzYUfiIfVi3JObNFXp5Di1z5dmZms9yaInpRL4Q=; b=kajKFWN3bA9lCzyf/dnhMpTCO5 6aF9PlVayhwyaYtGUqFeVoRlBRJ7riI4l6hF8M0uot9jWKKo8gFOQaS3jJqXo4nWuEmlPgI+XZpKm oDNzO1SpKjoQMojsfnXgCTALwn8MCL/sci+S5Kx4lsHOAgIyEnN2Vzxq0HN0U3DQYUYPqaS1Za3Xx 1LSrFofzO+acGInlzWFL2ERLx/x4NkLGYe+Zp3CfLWZLoDl5eTJxBf9Is2pHg9UFFDNrA0RtA5g/K q7AKzdwsatVQuN0YxKt8t7gXW1kM8jxmW3oZkBtCVZg0YKqVy8x+KerkwZFdqVuW0ONY5TSrlN/kH QSJxQkrQ==; Received: by zero.zsh.org with local id 1rOUMj-0009CD-J4; Sat, 13 Jan 2024 03:07:21 +0000 Authentication-Results: zsh.org; iprev=pass (mta01.eastlink.ca) smtp.remote-ip=24.224.136.30; dmarc=none header.from=eastlink.ca; arc=none Received: from mta01.eastlink.ca ([24.224.136.30]:46315) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rOULg-0008VW-Bf; Sat, 13 Jan 2024 03:06:17 +0000 Received: from csp02.eastlink.ca ([71.7.199.167]) by mta01.eastlink.ca ([24.224.136.30]) with ESMTPS id <0S762GX9MJ8DU970@mta01.eastlink.ca> for zsh-users@zsh.org; Fri, 12 Jan 2024 23:06:15 -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 OULerZY6rtqGEOULerEvWp (version=TLSv1_2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256); Fri, 12 Jan 2024 23:06:15 -0400 X-Authority-Analysis: v=2.4 cv=Zvoraf3G c=1 sm=1 tr=0 ts=65a1fe27 a=e7T7DzMKK1R988ZCg0wLyw==:117 a=e7T7DzMKK1R988ZCg0wLyw==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=abrK2jI4kOPGGG9gG5YA:9 a=QEXdDO2ut3YA:10 a=pGLkceISAAAA:8 a=xVqWdd8aGGE0DlqVkywA:9 a=vxeE7RToJrAb9W8r:21 a=_W_S_7VecoQA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdeiiedgheefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurheptgfkffggfgfuvfhfhfgjsegrtderredtvdejnecuhfhrohhmpeftrgihucetnhgurhgvfihsuceorhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrqeenucggtffrrghtthgvrhhnpefhteethfevgeeuvdelgefgvdevudefueduffdvgfelvddvgfdtieegueeuleeifeenucfkphepvdegrddvtdejrdduledrudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrdduledrudefpdhhvghloheplgduledvrdduieekrddtrdduudgnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepreerpdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Content-type: multipart/alternative; boundary="------------V7eKyfjv7Dn7AgTmQy2SurYO" Message-id: <93206b56-b303-460f-a373-fc8ac77e2865@eastlink.ca> Date: Fri, 12 Jan 2024 19:06:14 -0800 MIME-version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Fwd: more splitting travails Content-language: en-US To: zsh-users@zsh.org References: <205735b2-11e1-4b5e-baa2-7418753f591f@eastlink.ca> From: Ray Andrews In-reply-to: X-Seq: 29458 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. --------------V7eKyfjv7Dn7AgTmQy2SurYO Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024-01-12 14:09, Bart Schaefer wrote: > Yeah, oddly, there's no straightforward way to get an unaltered file > into a shell variable. Even > read -rd '' < file > trims off trailing newlines. In my situation that would be welcome, tho on principle I do wish the culture was: 'If I want something done to my data I'll ask for it'. > I'm expecting Roman or someone to point out a different trick I've forgotten. Roman would know.  I have my utility working quite well,   where the input isn't an array it's very simple:     % varis variable Without the dollar sign.  It evals it internally *after* capturing the name. You put the utility inside some function to trace variable values, it prints out like: / / function test1 () { local my_variable="Shall I compare thee to a summer\'s day?" varis my_variable "some comment" } 0 /aWorking/Zsh/Source/Wk 1 % . test1; test1 ... test1():4 in: test1:6 > "$my_variable" is: |Shall I compare thee to a summer's day?| some comment - 18:33:06 ... It reports name of function, logical line, running file, physical line, name of variable, content, some comment if present and the time.  I love it.  Anyway, it was all good except that arrays print on multiple lines if requested and they were not showing any blank lines, which I object to on principle -- so I'm trying to fix that.  It's 99% there: 0 /aWorking/Zsh/Source/Wk 1 % print -l "$vvar[@]"     # What it really looks like. one two three four five six seven eight 0 /aWorking/Zsh/Source/Wk 1 % varis ,m vvar ! this is comment     # squashed array, usually fine but ... zsh():15 in: zsh:15 > "$vvar" is: one two three four five six seven eight ! this is comment - 18:41:06 0 /aWorking/Zsh/Source/Wk 1 % varis ,m "${(@f)vvar}" ! this is comment     # ... when I'm determined to see the blanks: zsh():16 in: zsh:16 > RAW: one two three four five six seven eight this is comment - 18:41:13 ... as discussed I have to twist the shell's arm to get my file into a variable as it actually is.  In practice it's not a big deal but on principle it would be nice to avoid "  "${(@f) var}" " This sure looks good: 0 /aWorking/Zsh/Source/Wk 0 % read -rd '' < testfile2 aaa 0 /aWorking/Zsh/Source/Wk 0 % print -l $aaa     # Sheesh, it's so simple here. one two three four five six seven eight --------------V7eKyfjv7Dn7AgTmQy2SurYO Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 2024-01-12 14:09, Bart Schaefer wrote:
Yeah, oddly, there's no straightforward way to get an unaltered file
into a shell variable.  Even
  read -rd '' < file
trims off trailing newlines. 

In my situation that would be welcome, tho on principle I do wish the culture was: 'If I want something done to my data I'll ask for it'.

I'm expecting Roman or someone to point out a different trick I've forgotten.

Roman would know.  I have my utility working quite well,   where the input isn't an array it's very simple:

    % varis variable

Without the dollar sign.  It evals it internally *after* capturing the name. You put the utility inside some function to trace variable values, it prints out like:


function test1 ()
{

local my_variable="Shall I compare thee to a summer\'s day?"
varis my_variable "some comment"
}

0 /aWorking/Zsh/Source/Wk 1 % . test1; test1

...

test1():4 in: test1:6 > "$my_variable" is: |Shall I compare thee to a summer's day?| some comment - 18:33:06

... It reports name of function, logical line, running file, physical line, name of variable, content, some comment if present and the time.  I love it.  Anyway, it was all good except that arrays print on multiple lines if requested and they were not showing any blank lines, which I object to on principle -- so I'm trying to fix that.  It's 99% there:

0 /aWorking/Zsh/Source/Wk 1 % print -l "$vvar[@]"     # What it really looks like.                         
one two
three

four

five six seven


eight

0 /aWorking/Zsh/Source/Wk 1 % varis ,m vvar ! this is comment     # squashed array, usually fine but ...

zsh():15 in: zsh:15 > "$vvar" is:
one two
three
four
five six seven
eight
! this is comment - 18:41:06

0 /aWorking/Zsh/Source/Wk 1 % varis ,m "${(@f)vvar}" ! this is comment     # ... when I'm determined to see the blanks:

zsh():16 in: zsh:16 > RAW:
one two
three

four

five six seven


eight




this is comment - 18:41:13


... as discussed I have to twist the shell's arm to get my file into a variable as it actually is.  In practice it's not a big deal but on principle it would be nice to avoid "  "${(@f) var}"  "

This sure looks good:

0 /aWorking/Zsh/Source/Wk 0 % read -rd '' < testfile2 aaa

0 /aWorking/Zsh/Source/Wk 0 % print -l $aaa     # Sheesh, it's so simple here.       
one two
three

four

five six seven


eight


--------------V7eKyfjv7Dn7AgTmQy2SurYO--