Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

git-info ahead/behind check broken #566

Closed
pikeas opened this Issue · 13 comments

2 participants

@pikeas

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

What's your Zsh version?

@pikeas

zsh 5.0.2

@sorin-ionescu

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

@pikeas

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

Still broken.

@sorin-ionescu

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

@pikeas

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

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

@pikeas

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

@sorin-ionescu

No.

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

@pikeas

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

It's documented in man zshexpn.

What about (W: :)?

@sorin-ionescu

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

@pikeas

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

@pikeas pikeas closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.