* Odd behavior of quoted Zsh array subtraction
@ 2021-07-23 9:39 Zach Riggle
2021-07-23 9:51 ` Mikael Magnusson
0 siblings, 1 reply; 4+ messages in thread
From: Zach Riggle @ 2021-07-23 9:39 UTC (permalink / raw)
To: zsh-users
I'm sure there's a section of the manual that explains this.
I'm also sure I don't know what section it is.
$ a=( aa bb cc dd ee )
$ b=( cc )
$ echo ${a:|b}
aa bb dd ee
$ echo "${a:|b}"
aa bb cc dd ee # <-- WHAT
$ echo "${(@)a:|b}"
aa bb dd ee
$ echo "${a[@]:|b}"
aa bb dd ee
All results except the first quoted expression is the expected result.
Why does the marked, quoted array-subtraction result in a different
set of values? I would expect that array operators have precedence
over array-converted-to-scalar. Maybe this is an "outward-in"
expansion issue?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Odd behavior of quoted Zsh array subtraction
2021-07-23 9:39 Odd behavior of quoted Zsh array subtraction Zach Riggle
@ 2021-07-23 9:51 ` Mikael Magnusson
2021-07-23 11:38 ` René Neumann
2021-07-23 17:34 ` Bart Schaefer
0 siblings, 2 replies; 4+ messages in thread
From: Mikael Magnusson @ 2021-07-23 9:51 UTC (permalink / raw)
To: Zach Riggle; +Cc: zsh-users
On 7/23/21, Zach Riggle <zachriggle@gmail.com> wrote:
> I'm sure there's a section of the manual that explains this.
>
> I'm also sure I don't know what section it is.
If you search for "brain damage" in the zshall manpage, you will find
it. You are in particular interested in the ordering relation between
item 5 and item 7.
> $ a=( aa bb cc dd ee )
>
> $ b=( cc )
>
> $ echo ${a:|b}
> aa bb dd ee
>
> $ echo "${a:|b}"
> aa bb cc dd ee # <-- WHAT
>
> $ echo "${(@)a:|b}"
> aa bb dd ee
>
> $ echo "${a[@]:|b}"
> aa bb dd ee
>
> All results except the first quoted expression is the expected result.
>
> Why does the marked, quoted array-subtraction result in a different
> set of values? I would expect that array operators have precedence
> over array-converted-to-scalar. Maybe this is an "outward-in"
> expansion issue?
Your expectation is simply not matching what the code does, if the
current level is double quoted then words will be joined before
history modifiers are applied.
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Odd behavior of quoted Zsh array subtraction
2021-07-23 9:51 ` Mikael Magnusson
@ 2021-07-23 11:38 ` René Neumann
2021-07-23 17:34 ` Bart Schaefer
1 sibling, 0 replies; 4+ messages in thread
From: René Neumann @ 2021-07-23 11:38 UTC (permalink / raw)
To: zsh-users
> If you search for "brain damage" in the zshall manpage, you will find
> it.
For those readers who think this is some sarcastic remark (like I did at
first): No, it yields exactly the right spot.
</PSA>
- René
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Odd behavior of quoted Zsh array subtraction
2021-07-23 9:51 ` Mikael Magnusson
2021-07-23 11:38 ` René Neumann
@ 2021-07-23 17:34 ` Bart Schaefer
1 sibling, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2021-07-23 17:34 UTC (permalink / raw)
To: Mikael Magnusson; +Cc: Zach Riggle, Zsh Users
On Fri, Jul 23, 2021 at 2:51 AM Mikael Magnusson <mikachu@gmail.com> wrote:
>
> You are in particular interested in the ordering relation between
> item 5 and item 7. [...] if the
> current level is double quoted then words will be joined before
> history modifiers are applied.
This is correct, but item 7 sort of sweeps up :| and :* (etc.) by
accident, because they aren't really history modifiers. For example,
// is called out explicitly there, but :/ is not. Item 7 has not been
kept up to date with several of the more recently added forms of
parameter manipulation.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-07-23 17:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23 9:39 Odd behavior of quoted Zsh array subtraction Zach Riggle
2021-07-23 9:51 ` Mikael Magnusson
2021-07-23 11:38 ` René Neumann
2021-07-23 17:34 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).