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

git-info ahead/behind check broken #566

Closed
pikeas opened this issue Feb 28, 2014 · 18 comments
Closed

git-info ahead/behind check broken #566

pikeas opened this issue Feb 28, 2014 · 18 comments

Comments

@pikeas
Copy link

pikeas commented Feb 28, 2014

I'm setting up a new Mac, so everything is up-to-date - latest OS X Mavericks, latest clone of prezto, etc. Git version is 1.8.3.4.

Symptom: After every shell command, the following is output:

git-info:165: bad math expression: operator expected at `0'
git-info:173: bad math expression: operator expected at `0'

I did some digging in that file (modules/git/functions/git-info). From line 250 (not either of the lines from the error, interestingly), we have:

ahead_and_behind_cmd='git rev-list --count --left-right HEAD...@{upstream}'
ahead_and_behind="$(${(z)ahead_and_behind_cmd} 2> /dev/null)"

if [[ -n "$ahead_format" ]]; then
  ahead="$ahead_and_behind[(w)1]"
  if (( ahead > 0 )); then

$ahead is set to (num)(some sort of whitespace)(num), which means the [(w)1] has failed to split the string, which then causes the comparison to zero to throw an error.

My shell-fu is not strong, so I don't know how to correctly split $ahead_or_behind.

@sorin-ionescu
Copy link
Owner

What's your Zsh version?

@pikeas
Copy link
Author

pikeas commented Feb 28, 2014

zsh 5.0.2

@sorin-ionescu
Copy link
Owner

If you install the latest Zsh from Homebrew, does it still occur?

@pikeas
Copy link
Author

pikeas commented Feb 28, 2014

Installed zsh 5.0.5, which is the version present on brew.

Still broken.

@sorin-ionescu
Copy link
Owner

I'm sorry, but I can't replicate this. It works on my end.

@pikeas
Copy link
Author

pikeas commented Mar 1, 2014

Is there anything else I can do to help test and figure this out? Prezto is really critical to my workflow.

Since this is a fresh install of OS X Mavericks on a new machine, I'd expect this to affect more users over time as they upgrade their OS and/or machine. Let's get to the bottom of this. :-)

@sorin-ionescu
Copy link
Owner

If you can share the code, zip up your repository as is on your machine and let me download it.

@pikeas
Copy link
Author

pikeas commented Mar 1, 2014

Just recloned your repo, same problem. Do you still want a zip?

@sorin-ionescu
Copy link
Owner

No.

What happens if you change ahead to $ahead in the if statement?

@pikeas
Copy link
Author

pikeas commented Mar 1, 2014

Doesn't help, because ahead is set to (NUM1) (NUM2). It's the [(w)1] that's causing the issue, it's not pulling out NUM1 as expected.

@sorin-ionescu
Copy link
Owner

It's documented in man zshexpn.

What about (W: :)?

@sorin-ionescu
Copy link
Owner

If you have an IRC client, #zsh on Freenode may be of help as well.

@pikeas
Copy link
Author

pikeas commented Mar 3, 2014

The culprit turned out to be a virtualenv postactivate script which modified IFS and didn't unset it when finished.

@pikeas pikeas closed this as completed Mar 3, 2014
@michaelaye
Copy link

Hey @pikeas could you be more specific what your problem was (if you remember)? What is IFS and how did you figure it out? I'm having the same problem, even with the newest zsh and prezto, after it was working for a long time, haven't a clue what changed. :(

@pikeas
Copy link
Author

pikeas commented Jul 27, 2016

IFS is the separator character - https://en.wikipedia.org/wiki/Internal_field_separator

@Po-Hsuan-Huang
Copy link

@pikeas can you write a patch for the issue, or post where the error is and how to solve it ? Thanks a lot !

@pikeas
Copy link
Author

pikeas commented Jun 3, 2017

@Po-Hsuan-Huang Check to see if other software (in my case it was a Python virtualenv postactivate script) sets the IFS environment variable and doesn't unset it.

@michaelaye
Copy link

Yes. For me it was the conda env manager not unsetting the IFS, which is fixed now.

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

No branches or pull requests

4 participants