zsh-users / zsh-syntax-highlighting

Fish shell like syntax highlighting for Zsh.
github.com/zsh-users/zsh-syntax-highlighting
BSD 3-Clause "New" or "Revised" License
19.92k stars 1.32k forks source link

command word: Order of expansions is wrong #264

Open danielshahaf opened 8 years ago

danielshahaf commented 8 years ago

https://github.com/zsh-users/zsh-syntax-highlighting/blob/5e4b446dee770a811ffb6c19ee41f624895e56da/highlighters/main/main-highlighter.zsh#L275-L300

As zshexpn(1) specifies, alias expansion precedes parameter expansion which precedes tilde expansion. However, the code implements them in a different order (e.g., tilde expansion is performed before alias expansion).

phy1729 commented 5 years ago

The expansion order is now: alias, tilde, parameter; however one should note that

foo='~root'
echo $foo

does not expand to /root, so we should keep track of quoting if the order is fixed.

danielshahaf commented 4 years ago

I think nowadays we could implement that easily by having _zsh_highlight_main_highlighter_expand_path check (( in_param )). Test case: set a=/usr then type $a in command position (without a trailing space).

danielshahaf commented 4 years ago

Triage: https://github.com/zsh-users/zsh-syntax-highlighting/pull/471#issuecomment-632473281