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

An error under zsh 5.0.0: "geometry::info:local:2: not valid in this context: ..." #246

Closed
psprint opened this issue Jan 10, 2019 · 17 comments
Milestone

Comments

@psprint
Copy link

psprint commented Jan 10, 2019

The error message appearing when running under zsh-5.0.0:

geometry::info:local:2: not valid in this context: %F{blue}%(1j.\u2699
@jedahan
Copy link
Member

jedahan commented Jan 10, 2019

I removed the local from that function, and quotes some things. Care to test again? Also I'm going to have to figure out how to test on different zsh versions.

@jedahan
Copy link
Member

jedahan commented Jan 10, 2019

I added a Dockerfile to test zsh-5.0.0

@jedahan jedahan added this to the 2.0.0 milestone Jan 15, 2019
@jedahan
Copy link
Member

jedahan commented Feb 23, 2019

are you still getting this issue?

@psprint
Copy link
Author

psprint commented Feb 23, 2019

Yes :)

@jedahan
Copy link
Member

jedahan commented May 27, 2019

I made a Dockerfile using zsh-users-5.0.0 but I get a different error

@jedahan
Copy link
Member

jedahan commented May 27, 2019

So I'm having trouble reproducing this issue on the latest mnml branch. I made a Dockerfile that should provide a common environment to test for the issue, but I'm at a loss of how to debug.

@jedahan
Copy link
Member

jedahan commented May 27, 2019

There was a bugfix branch from a few years ago, that changed instances of local _ctx_plugins=() to twoliners, local _ctx_plugins; _ctx_plugins=(). Should investigate those fixes as well.

@jedahan
Copy link
Member

jedahan commented Aug 21, 2019

Is this still a problem?

@jedahan
Copy link
Member

jedahan commented Aug 21, 2019

Running in the dockerfile, this seems to be fixed.

@jedahan jedahan closed this as completed Aug 21, 2019
@psprint
Copy link
Author

psprint commented Aug 22, 2019

I've just checked, both geometry and mnml doesn't yield this error

@psprint
Copy link
Author

psprint commented Aug 22, 2019

Too early a success call – I've just got:

mnml::wrap:local:7: not valid in this context: %F{red}3%f$MNML_GIT_SEPARATOR%F{red}\u2b21%f
mnml::wrap:local:7: not valid in this context: %F{red}3%f$MNML_GIT_SEPARATOR%F{red}\u2b21%f
mnml::wrap:local:7: not valid in this context: %F{red}3%f$MNML_GIT_SEPARATOR%F{red}\u2b21%f

and it seems to come from zsh-5.7.1:
mnml-error

@jedahan
Copy link
Member

jedahan commented Aug 22, 2019

Can you get that error using the dockerfile? Because I tried 5.7.1 and it seems to be working...

@jedahan
Copy link
Member

jedahan commented Aug 22, 2019

Also might have to do with some quoting zsh-users/zsh-autosuggestions#127

@jedahan jedahan reopened this Aug 22, 2019
@psprint
Copy link
Author

psprint commented Aug 31, 2019

So the local var=$( ... ) should be changed to a quoted version local var="$( ... )". I did a quick search and found a few of such cases:

 ▲ .zplugin/plugins/geometry-zsh---geometry ack local.\*'[^"]\$\('     mnml 9d :: ⬡
functions/geometry_hg.zsh
7:  local branch="$(ansi ${GEOMETRY_HG_COLOR_BRANCH:=242} $(hg branch 2> /dev/null))"
10:    && local symbol=$(ansi ${GEOMETRY_HG_COLOR_DIRTY:=red} ${GEOMETRY_HG_SYMBOL_DIRTY:="⬡"}) \
11:    || local symbol=$(ansi ${GEOMETRY_HG_COLOR_CLEAN:=green} ${GEOMETRY_HG_SYMBOL_CLEAN:="⬢"})

functions/geometry_rust_version.zsh
6:      local rust_version=$(rustc --version | \grep --color=never -oE '[0-9]+\.[0-9]+\.[0-9]')

functions/geometry_git.zsh
55:  local_commit=$(git rev-parse "@" 2>/dev/null)

functions/geometry_status.zsh
20:    local sum=0; for c in ${(s::)^HOST}; do ((sum += $(print -f '%d' "'$c"))); done
22:    local index=$(($sum % ${#colors}))

functions/geometry_npm_package_version.zsh
10:     local npm_package_version=$(\grep version package.json | \grep --color=never -oE '[0-9]+\.[0-9]+\.[0-9]')
12:    local symbol=$(ansi $GEOMETRY_NPM_PACKAGE_VERSION_SYMBOL_COLOR $GEOMETRY_NPM_PACKAGE_SYMBOL)
13:    local version=$(ansi $GEOMETRY_NPM_PACKAGE_VERSION_COLOR v$npm_package_version)

Zsh 5.0 is now 7 years old, but maybe it's worth to fix this.

@jedahan
Copy link
Member

jedahan commented Oct 5, 2019

I'm not sure I can fix line 20 of geometry_status, because of the quotes in quotes. Will zsh understand
sum += "$(print -f '%d' "'$c")"?

@jedahan
Copy link
Member

jedahan commented Oct 5, 2019

Quoted profusely in 75b6a1b

@jedahan jedahan closed this as completed Oct 5, 2019
@psprint
Copy link
Author

psprint commented Oct 5, 2019

Yes I think that Zsh properly understands such embedded quoting.

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