mattmc3 / antidote

https://getantidote.github.io - the cure to slow zsh plugin management
MIT License
904 stars 21 forks source link

zsh option POSIX_IDENTIFIERS breaks in __antidote_main and antidote-help #86

Closed Cueball closed 1 year ago

Cueball commented 1 year ago

Just in the midst of redoing my dotfiles and moving to antidote.

Installed antidote, launched it for the first time and it generated the following errors when invoking the antidote command:

__antidote_main:14: bad math expression: operator expected at `o_version '
__antidote_main:20: bad math expression: operator expected at `o_help '
antidote-help:35: bad math expression: operator expected at `o_help '
antidote - the cure to slow zsh plugin management [etc...]

After some hunting, I found that having the zsh option POSIX_IDENTIFIERS set will reliably reproduce this issue. Running setopt NO_POSIX_IDENTIFIERS; antidote immediately works without issue.

In the antidote.zsh file, it's due to lines like: if (( $#o_version )); then where $# is, according to the man page:

In addition, setting this option limits the effect of parameter substitution
with no braces, so that the expression $# is treated as the parameter $# even
if followed by a valid parameter name. When it is unset, zsh allows
expressions of the form $#name to refer to the length of $name, even for
special variables, for example in expressions such as $#- and $#*.

The way I read that is that expressions like $#o_version needs to be changed to ${#o_version}. I expect this change should have no effect upon the code with POSIX_IDENTIFIERS unset?

[I've had this collection of zsh options set for ages without issue (worked with zinit and whatever I used before that). I'm pretty sure I've isolated this properly but I'm also way overdue for bed, so... šŸ™ƒ]

mattmc3 commented 1 year ago

Sorry to hear you had a bad experience with antidote @Cueball. I thought I had thoroughly tested with every one of the zillions of setopts enabled, but clearly I missed being thorough with this one. I've added a test specifically for this and have published a fix. Let me know if it works for you. If so, I'll tag a new release.

Cueball commented 1 year ago

LGTM. šŸš¢

Did need to switch from the brew version to the git version, but I don't see that making a difference. I had patched the local version enough to keep me rolling, but your test coverage looks like it's picked up a lot more changes that I hadn't even considered. (Honest, that's an useful test framework there; I'll have to check it out next time I have to build something script-based.)

Thanks for the prompt fix for my shell option weirdness lol šŸ‘

mattmc3 commented 1 year ago

Once I bump the version, I will republish to brew so you will be switch back once that goes live.