Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: psychiatric help
- X-seq: zsh-users 30485
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Cc: zsh-users@xxxxxxx
- Subject: Re: psychiatric help
- Date: Sat, 4 Apr 2026 20:57:54 -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=QgihNCeMCZXy+JfhlODYlLyXMjX3x/vThlo4bPklyf4=; fh=D6X9xIaVjTSxb6gwuCseglo0uxyISp24IsyxMp5sRU4=; b=WbXXNFMLKze8ZWW0vXGy+S5gJoAFfg36LfDN6jF2TMMyLnw5GKCIpdo+ca6r/oSYKo UPSyIHM7Y3FxSGKrdIIC1ZjZO8I+X10fagIactdjf8qq4ehvJj8juM+fEix3eYs2/bjT flsHVhoV4oy6A1dvzEWG58mdsPkcPIFCMRgMbHJEP4kNUEOudBKWFK+9pV3uUmIkGutW yDDs7OMfoUmq75SgW7QqH59Jnj5b+xUGmmcovjCf39UruuGKlE4noQjcIuH1eAXWNTuB c1qCIV4V0C5oExbeyQbdwy4ZHdJjmb4DYxj+8phj+iFeZqTr59w0zbIUrCow4fCjAirX uuJg==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1775361486; cv=none; d=google.com; s=arc-20240605; b=EaXE2yeYdkJFjrsDStJ4azfWQoHYEQ0HEkVk3Kt4/DdKD92a7WJ336QlSffXLssAGt KjasfW7k8cENlfGcob3NjN3M70JfcukWqr8ys4sMAgAekUfqSnT9rl0lKV4+neUmp68k f68svKzt1hTDTdRjAwR2N3RAUFebHPq6vCdNgzdx3bsCZvJ48b+p7gMRmneMbD50HwM6 iMi+pSA1WnlmYBS9ZBn1F+Z/RGg4d54Q5Wg5/2EN9OA+UBMiM520XYpJtoDKRexo+Wvq 9SC5CkHjSXRH/Dv4y53woSk3/iClG/DQQdeb4Ni9IKpjrQCEPpamCc71tUHqISnTqdvw kYtA==
- Archived-at: <https://zsh.org/users/30485>
- In-reply-to: <755f4aa9-e27a-4b4d-8f23-add76a13ee83@eastlink.ca>
- List-id: <zsh-users.zsh.org>
- References: <0610849d-f81c-4539-b13d-c4be9cbd1276@eastlink.ca> <CAA=-s3yUhzu7WbAB0F09abwmzPYowJ1s6o+YiV+cuQBf-GvFXw@mail.gmail.com> <448d6d35-c261-4e7e-bc67-c2a58d082b87@eastlink.ca> <CAA=-s3wKQb+1Sq2mV+h2Gk8rOQYKt8x_JNg9NhmdwAgJesxBkQ@mail.gmail.com> <755f4aa9-e27a-4b4d-8f23-add76a13ee83@eastlink.ca>
On Sat, Apr 4, 2026 at 4:24 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> Problem is when the command tail has to be passed on to another function
By "the command tail" you mean the positional parameters? $*, $@, or
$1, $2, $3, ... ?
> internally so I have no chance to edit it. Hard spaces are going to
> become soft spaces.
"Hard" (previously quoted) spaces only become "soft" (unquoted) spaces
when, well, you don't quote them.
On top of that, though, in zsh, quoted spaces only become unquoted
when you explicitly unquote them. There are a bunch of ways to do
that, but the most common are
- setopt sh_word_split
- ${=var} (temporarily sh_word_split)
- eval
I'm reasonably sure you're not doing sh_word_split, but based on your
history of questions you have a habit of using eval.
I think you're also a bit unclear on the concept of arrays and of
using double-quotes.
$* and $@ (and $argv) are arrays, having the same elements. Unless
you mean for their value to be converted to a string, you should use
array operations on them. That means you should NOT do
out=${@//\ /\\ }
because that is a string (scalar) assignment, so all the elements of
the $@ array get concatenated together into a single string as the
value of $out. That puts you in the position of having to split $out
apart again to use the array elements. Given your focus on keeping
the backslashes, I'd be willing to bet you're doing that with eval.
If you need to copy $@ (et al.) into another variable, use array syntax:
out=( $@ )
That preserves all your "hard" spaces in each of the elements of the
array $out. Of course if you need to do some other manipulation of
the individual element values, there may be complications, but the
basic idea is to stop needlessly converting arrays to strings and
back.
A refresher on $* and $@ and quoting ...
These are equivalent (assuming no_sh_word_split):
ary=( $* )
ary=( $@ )
ary=( "$@" )
These are also equivalent:
str=$*
str=$@
str="$*"
Notice how "$@" and "$*" differ.
"$*" is like "$1 $2 $3 ..."
"$@" is like "$1" "$2" "$3" ...
That last example preserves "hard" spaces even when sh_word_split is
set, so if you think your code might run in a context where you don't
know, use "$@" for safety.
Consequently if you have
function tail_call {
print -rC1 -- "$@"
}
function call {
tail_call "$@"
}
You can be sure that
call test\ ?
will, in your example directory, output
test a
test b
> I always thought that permitting spaces in
> designators was a bad idea from the getgo. Should never have been permitted.
Sadly, I don't know what you mean by "designators".
Messages sorted by:
Reverse Date,
Date,
Thread,
Author