zsh-syntax-highlighting icon indicating copy to clipboard operation
zsh-syntax-highlighting copied to clipboard

history-expansion does not highlight & (previous substitution modifier) character

Open zaidhaan opened this issue 1 year ago • 2 comments

Screenshot: (note that expansion does work as expected after hitting return. & however, is not highlighted) image

Reproducible setup:

$ echo foo_replaceme_bar
$ echo baz_replaceme_qux
$ !-2:s/replaceme/subst/ && !-1:&   

Relevant zsh manual section: 14.1.4 Modifiers.

& Repeat the previous s substitution. Like s, may be preceded immediately by a g. In parameter expansion the & must appear inside braces, and in filename generation it must be quoted with a backslash.

I'm no zsh expert but I think all modifiers apply to history expansions too, so the modifier & should be also be highlighted in history-expansion.

zaidhaan avatar Jun 03 '23 04:06 zaidhaan

Looks like this is a zsh bug

printf '<%s>' ${(z)${:-'!-2:&'}}
<!-2:><&>

(That means the (z) PE flag is splitting the & into a separate token when it should be all one token.)

phy1729 avatar Jun 03 '23 04:06 phy1729

Looks like this is a zsh bug

Reported at https://zsh.org/workers/51819

zaidhaan avatar Jun 03 '23 06:06 zaidhaan