# BUG: git prompt breaks with zsh < 5.0.6

3 messages from 2023-01-09 to 2023-01-10. Participants: Shupak, Vitaly, brian m. carlson.
Thread: https://gitlist.dev/t/59060

## Shupak, Vitaly, 2023-01-09 17:12

Subject: BUG: git prompt breaks with zsh < 5.0.6
Message-ID: <5807cdbe6d66427c9ff45ea78c2c1ffb@deshaw.com>
URL: https://gitlist.dev/e/5807cdbe6d66427c9ff45ea78c2c1ffb%40deshaw.com

```
A change to git-prompt.sh in v2.38 to show presence of unresolved conflicts contains syntax which is not valid under zsh < 5.0.6. This version of zsh is old, but is still the default on RedHat 7 machines, for example.

The offending block is:

       local conflict="" # state indicator for unresolved conflicts
       if [[ "${GIT_PS1_SHOWCONFLICTSTATE}" == "yes" ]] &&
          [[ $(git ls-files --unmerged 2>/dev/null) ]]; then
               conflict="|CONFLICT"
       fi

[[ $(command) ]] syntax doesn't work in older version of zsh and should use [[ -n "$(command)" ]] instead.

Thanks,
Vitaly


```

## brian m. carlson, 2023-01-09 23:37

Subject: Re: BUG: git prompt breaks with zsh < 5.0.6
Message-ID: <Y7ylHW8nrsT1eVtW@tapette.crustytoothpaste.net>
URL: https://gitlist.dev/e/Y7ylHW8nrsT1eVtW%40tapette.crustytoothpaste.net
In-Reply-To: <5807cdbe6d66427c9ff45ea78c2c1ffb@deshaw.com>

```
On 2023-01-09 at 17:12:56, Shupak, Vitaly wrote:
> A change to git-prompt.sh in v2.38 to show presence of unresolved conflicts contains syntax which is not valid under zsh < 5.0.6. This version of zsh is old, but is still the default on RedHat 7 machines, for example.
> 
> The offending block is:
> 
>        local conflict="" # state indicator for unresolved conflicts
>        if [[ "${GIT_PS1_SHOWCONFLICTSTATE}" == "yes" ]] &&
>           [[ $(git ls-files --unmerged 2>/dev/null) ]]; then
>                conflict="|CONFLICT"
>        fi
> 
> [[ $(command) ]] syntax doesn't work in older version of zsh and should use [[ -n "$(command)" ]] instead.

Does [ "$(command)" ] work?  I would assume so, because that's in POSIX.
If so, that might also be a valid approach since it doesn't look like we
need the special behaviour of the double-bracket operator.
-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA

```

## Shupak, Vitaly, 2023-01-10 15:15

Subject: RE: BUG: git prompt breaks with zsh < 5.0.6
Message-ID: <f1610b3f00284e69a089d40c7182a8ab@deshaw.com>
URL: https://gitlist.dev/e/f1610b3f00284e69a089d40c7182a8ab%40deshaw.com
In-Reply-To: <Y7ylHW8nrsT1eVtW@tapette.crustytoothpaste.net>

```
Yes, that works too

-----Original Message-----
From: brian m. carlson <sandals@crustytoothpaste.net> 
Sent: Monday, January 9, 2023 6:37 PM
To: Shupak, Vitaly <Vitaly.Shupak@deshaw.com>
Cc: git@vger.kernel.org
Subject: Re: BUG: git prompt breaks with zsh < 5.0.6

On 2023-01-09 at 17:12:56, Shupak, Vitaly wrote:
> A change to git-prompt.sh in v2.38 to show presence of unresolved conflicts contains syntax which is not valid under zsh < 5.0.6. This version of zsh is old, but is still the default on RedHat 7 machines, for example.
> 
> The offending block is:
> 
>        local conflict="" # state indicator for unresolved conflicts
>        if [[ "${GIT_PS1_SHOWCONFLICTSTATE}" == "yes" ]] &&
>           [[ $(git ls-files --unmerged 2>/dev/null) ]]; then
>                conflict="|CONFLICT"
>        fi
> 
> [[ $(command) ]] syntax doesn't work in older version of zsh and should use [[ -n "$(command)" ]] instead.

Does [ "$(command)" ] work?  I would assume so, because that's in POSIX.
If so, that might also be a valid approach since it doesn't look like we need the special behaviour of the double-bracket operator.
--
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA

```
