Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: quoting curiosity
- X-seq: zsh-users 30752
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Ray Andrews <rayandrews@xxxxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: quoting curiosity
- Date: Sat, 7 Nov 2026 22:46:26 +0100
- 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-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=RG+KZeYGZt6Yu3UCOW4FbkrlGPXRvPcP44NrwEXL9ZQ=; fh=jPiVBPZEfwBf151+XrsNuwNUZll4fQOLSzRxlVE23MQ=; b=OXDyhk/6AGOi3EOIyXhlYKbG8yFMUItxpPAbZgNVeBd9tdpVpBrcec7HBHPmQjgwkh 2AyWEVVCa5nKIyuMt+pU5eL3iF9a+LCUqGIwCXSY81Aw7BeFhQ6rXhHJrVBEkoNEH+4H plPSqBSjGmbN0+LHxwDnAeNOSRVEN4lOG4q6AZ5HTBk0db94fhwHWd+S2t4iWZv3uTF+ 1eBV89D8diCCGsxi52QagaEYNGP8kHNz3gZVzK18aw0Fom4R1xy7JTh/JZT4oID+xE7E IU85lqa6QA9t0LK7X0/PGBWNeHWSQPHXk8DuC3bmHZJJl5As3ivOQTDA8xLZdL5lC02f 27tg==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1794087999; cv=none; d=google.com; s=arc-20260327; b=qVlRjtN58ahocAmZpS+pfgdjMyfE5bavjiMLgxjiALxUHHTgGtRtaK4RHIiw4WyRVL y3ElYCRxyz+KL1NsyRdzlXbJildezHQj98BYr6XL3SkFsH+zNPxtPTjfiRfLR4R4ypN4 fkcOYLplgWsQG2blFg+1ft1/sO5ZzU4uCTC9eKMR/foN0691W6v7EDoUpnoJ2hQSNRn0 1+Xfw/W+FvQzmM+04ZAZACb8XWIOc8j575g9kHwzYOSCF6J3Oq5jXjgam5IKvuIIxMzW lMTB/J1ePIznPyL1qckqTsB5ihe83teN118Sr+kY1T4TXQaFHoXJjzF81+c6an1oH2jX jFxA==
- Archived-at: <https://zsh.org/users/30752>
- In-reply-to: <d4ece9c6-177e-4497-adc4-f30695937e2c@eastlink.ca>
- List-id: <zsh-users.zsh.org>
- References: <d4ece9c6-177e-4497-adc4-f30695937e2c@eastlink.ca>
On Sat, Nov 7, 2026 at 6:56 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
>
> Doing some housekeeping in a utility of mine, and knowing that quotation is usually best -- besides it sets the color coding in my editor the way I like it -- I changed this:
>
> set -A "${IN[mouse_clicks]}" $Mclicks
>
> ... to this:
>
> set -A "${IN[mouse_clicks]}" "$Mclicks"
>
> ... and it broke the function. Why would that be? I haven't done any forensics on it at all, because maybe there's some simple, obvious reason.
% a=(1 2 3)
% print -l $a
1
2
3
% print -l "$a"
1 2 3
based on the -A in your `set -A`, i would assume that Mclicks is in
fact an array?
If you really want the quotes, you can use
% print -l "${(@)a}"
1
2
3
or
% print -l "$a[@]"
1
2
3
(the latter variant obviously only works if you want all members of
the array, while the former lets you write "${(@)a[1,3]}" or
whatever).
Long story short, unless you want to protect empty elements from being
elided, { eg if a=( 1 '' 3 ), then unquoted $a will expand to 1 and 3
(as separate elements), while "$a[@]" will expand to three elements
with the middle one being the empty string }, then just don't put the
quotes, in my opinion. Note that in neither case are spaces in element
values an issue, unless you have done setopt shwordsplit which would
be silly to do.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author