Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(eval):15 bad assignment when using '=' as alias #523

Closed
japborst opened this issue Aug 19, 2018 · 9 comments
Closed

(eval):15 bad assignment when using '=' as alias #523

japborst opened this issue Aug 19, 2018 · 9 comments

Comments

@japborst
Copy link

This is similar to #263 but I get a different error:

(eval):15: bad assignment

As a result, all plugin aliases are gone.

I'm using the zsh calc plugin, which aliases the =. When I remove this plugin, I get no errors and got all plugin aliases.

How can I best debug to provide more info?

@danielshahaf
Copy link
Member

Give the values of $ZSH_VERSION, $ZSH_PATCHLEVEL, $ZSH_HIGHLIGHT_REVISION, and $ZSH_HIGHLIGHT_VERSION; do set -x and post the last few lines; find a reproducer that starts with zsh -f and uses no external plugins. #263 involved patches both to zsh and to z-sy-h, but they've both been released some time ago.

Can you be a bit clearer about what your setup is and what the result is. Are you saying that with calc and z-sy-h the = alias is absent and with calc but without z-sy-h the = alias is present?

For reference, with current zsh and z-sy-h —

$ zsh -f
% aliases[=]='echo foo'          
% source ./zsh-syntax-highlighting.zsh 
./zsh-syntax-highlighting.zsh:31: invalid alias '=' encountered while printing aliases

@danielshahaf
Copy link
Member

Excuse brevity.

@japborst
Copy link
Author

My current set-up is the following:

zsh
oh-my-zsh
plugins=(
  calc
  zsh-syntax-highlighting
)
$ZSH_VERSION = 5.1.1
$ZSH_PATCHLEVEL = Debian
$ZSH_HIGHLIGHT_REVISION = HEAD
$ZSH_HIGHLIGHT_VERSION = 0.7.0-dev

Running on Bash for Windows with Ubuntu 16.04.5 LTS

With z-sy-h, but without the calc plugin:

alias -- -='cd -'
alias -g ...=../..
alias -g ....=../../..
alias -g .....=../../../..
alias -g ......=../../../../..
alias 1='cd -'
alias 2='cd -2'
alias 3='cd -3'
alias 4='cd -4'
alias 5='cd -5'
alias 6='cd -6'
alias 7='cd -7'
alias 8='cd -8'
alias 9='cd -9'
alias _=sudo
alias afind='ack -il'
alias d='dirs -v | head -10'
alias grep='grep  --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}'
alias history=omz_history
alias l='ls -lah'
alias la='ls -lAh'
alias ll='ls -lh'
alias ls='ls --color=tty'
alias lsa='ls -lah'
alias md='mkdir -p'
alias please=sudo
alias rd=rmdir
alias which-command=whence

With z-sy-h and the calc plugin:

alias -- -='cd -'
alias -g ...=../..
alias -g ....=../../..
alias -g .....=../../../..
alias -g ......=../../../../..
alias 1='cd -'
alias 2='cd -2'
alias 3='cd -3'
alias 4='cd -4'
alias 5='cd -5'
alias 6='cd -6'
alias 7='cd -7'
alias 8='cd -8'
alias 9='cd -9'

Without z-sy-h but with calc:

alias -- -='cd -'
alias -g ...=../..
alias -g ....=../../..
alias -g .....=../../../..
alias -g ......=../../../../..
alias 1='cd -'
alias 2='cd -2'
alias 3='cd -3'
alias 4='cd -4'
alias 5='cd -5'
alias 6='cd -6'
alias 7='cd -7'
alias 8='cd -8'
alias 9='cd -9'
alias '='='noglob __calc_plugin'
alias _=sudo
alias afind='ack -il'
alias calc='noglob __calc_plugin'
alias d='dirs -v | head -10'
alias grep='grep  --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}'
alias history=omz_history
alias l='ls -lah'
alias la='ls -lAh'
alias ll='ls -lh'
alias ls='ls --color=tty'
alias lsa='ls -lah'
alias md='mkdir -p'
alias please=sudo
alias rd=rmdir
alias which-command=whence

@japborst
Copy link
Author

This gives me a different error that you have:

zsh -f
SurfacePro3% aliases[=]='echo foo'
SurfacePro3% source ./zsh-syntax-highlighting.zsh
(eval):1: bad assignment

@japborst
Copy link
Author

Workaround is by sourcing manually after z-sy-h is sourced.

So in ~/.zshrc:
plugins=(... zsh-syntax-highlighting)
and at the very end:
source $ZSH_CUSTOM/plugins/calc/calc.plugin.zsh

@danielshahaf
Copy link
Member

The driver has code to undefine and redefine aliases before/after it's sourced. That's needed to be sure user aliases don't take effect in z-sy-h's code. The "redefine" code —

# Restore the aliases we unned
eval "$zsh_highlight__aliases"
builtin unset zsh_highlight__aliases
— must be what generates the error. It generates the error because your zsh is too old to have the zsh-side fixes for aliases with = in them (zsh-users/zsh@a8a00be, see also zsh-users/zsh@3a8727d)

I recommend that you upgrade zsh. (You seem to be on Debian jessie/oldstable. Debian stretch/stable is new enough.) Your workaround is good too.

To devs: 1. I'm not sure if calc defines widgets; if it does, the workaround would require redrawhook to be merged for full functionality; 2. if #252 were implemented it would sidestep this class of issues entirely.

@danielshahaf
Copy link
Member

An alternative workaround is to disable the undefine/redefine code: that's the chunk I linked plus the corresponding chunk at the top of the file that does unalias.

@japborst
Copy link
Author

It's just a simple wrapper function around zcalc:

https://github.com/arzzen/calc.plugin.zsh/blob/9b888dc78bf1c02fac77fa422ad1521440145b0c/calc.plugin.zsh#L2-L7

I was on Ubuntu/xenial but might be about time I switch to bionic. That'll update zsh as well. Will close the issue if that removes the issue :)

@danielshahaf
Copy link
Member

Sorry, but the issue tracker is our todo list, and I don't want to clutter it with open, inactionable issues. I'll close this issue now, but feel free to reopen if it occurs on zsh that has the aforementioned fixes (>=5.3.1) or if you have a patch to add support for older zsh's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants