Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: more splitting
- X-seq: zsh-users 30566
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Philippe Altherr <philippe.altherr@xxxxxxxxx>
- Cc: Ray Andrews <rayandrews@xxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: more splitting
- Date: Tue, 14 Apr 2026 19:02:59 -0700
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=zHO0KEAn9eq1CXpi5VoXt846OCi99e4MM5NRExBTDy4=; fh=6AVMiYQ0mN5iC7iO22Y3FeavYsqmXlj0csuvEsWytWY=; b=YrvSOaE1m2xF3csCvc6bsNMw5+kTyGE00pIQD3a6ESnEZ4STg7edvAyprizWTZgQf9 yurBGWiNNaumQYACmqsmTFfqu3JUcYNaBg56aN3tNP9519QeQ1IIBwz4Nu5TDCmE2z5+ RkWXanVDzJx0s3Ss3e6+RrnrsD6g2Rwt+s6EcXTv9vjn/b6umbQeuDCY24JhN695qWZa fuvVKCDEUTkhMJjvJ/SMsSBrgwz9lL+YJKeVPnbYRh8X5p9aBFuzIUhNWT5CBUXAo6gL /F5WKfkPhAHSWmAs471rFK/cerQz5ARVJXop0l7lp7clP4OOlZzZ/ugxAuUDAnZN6oxK IbDg==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1776218591; cv=none; d=google.com; s=arc-20240605; b=D7McKH+OAf8D+luyYioB00jxz7/Ph38sw5NZ1XayNZMoEyne0bYnCN1AnIVSvvE+aL HoW7iRqPwPMkgFbrbkvRkVRnDDVCq94nvBDtbU1ENPTt2hsBdSUtjhj62UUvrEHfm3VL po3EnATHZkrliKtkxGN5+TZImwKDbSVjnbFNgVZjKV3Yfxlj4FUfWbx3ht/u+ohQVoAx nKnpQn40/LEKbS7AE1nT7+CbTrHScuwvmWVf7bLDv8lFMuH5Fhcfj6vUb9Aap1qbtkZx pBplBCYEtnSS8NSev7uVswWiE2M3tpSY2XtM0PKUH0S+brghU1GnrwxPvBL5ZuFh67eM BEHA==
- Archived-at: <https://zsh.org/users/30566>
- In-reply-to: <CAGdYchuXfLZNBY2r8ztKuBrP17BN9UZ-jy_pOXtTHUesyMCL3Q@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <711e5b5f-5bd3-44e5-87a7-e18b0d670ae5@eastlink.ca> <CAGdYchuXfLZNBY2r8ztKuBrP17BN9UZ-jy_pOXtTHUesyMCL3Q@mail.gmail.com>
On Tue, Apr 14, 2026 at 4:24 PM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> What you try to do is pretty much impossible because when you do 'print -rn $var',you turn the strings in '$var' into a single one
Well, you can't do it with just "print" by itself.
> How is 'hex' supposed to know which of the spaces in that string were from the strings in '$var' and which ones were introduced to separate the strings in '$var'?!?
The trick is to restore some kind of quoting on $var. It's not
possible to restore exactly the original quoting but you can do as
well as "hex" itself does.
If "hex" looks like this ...
function hex ()
{
local var element
echo
if [[ -p /dev/fd/0 ]]; then
read -d '' -r var
set -- ${(z)var}
fi
print -rC1 -- ${(q+)${(Q)@}}
echo "\n-----------------------------\n"
for element ("$@") print -rn -- $element | od -vAx -tx1 -tc
}
Then:
print -rn ${(q+)var} | hex
does the same thing as
hex ${(q+)var}
but you can't avoid that (q+) on the way in to make it sane.
More later about $(<&0) ...
Messages sorted by:
Reverse Date,
Date,
Thread,
Author