git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] git-prompt.sh: Don't error on null ${ZSH,BASH}_VERSION, $short_sha

From
Ville Skyttä <ville.skytta@iki.fi>
Date
Jun 7, 2016, 05:22 UTC
Message-ID
<CABr9L5Bntn1+FGks6DfeJ6QMRr4CSHWwn8ggNGWroXe1kWczXQ@mail.gmail.com>
In-Reply-To
<xmqq37oqw05b.fsf@gitster.mtv.corp.google.com>
On Mon, Jun 6, 2016 at 11:08 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
> Ville Skyttä <ville.skytta@iki.fi> writes:
>
>> When the shell is in "nounset" or "set -u" mode, referencing unset or
>> null variables results in an error. Protect $ZSH_VERSION and
>> $BASH_VERSION against that, and initialize $short_sha before use.
>>
>> Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
>> ---
>
> Thanks for following up.  I do not run my interactive shells with
> "set -u", so I never noticed these, but apparently you do (or you
> know who does)

I don't personally, but some do. The issue pops up every now and then with bash-completion, e.g. https://github.com/scop/bash-completion/issues/44

> does this patch cover everything that is not "-u" safe?

I don't know. These were the low hanging fruits I've come across. Null $ZSH_VERSION in git-prompt.sh was the thing I ran into immediately when enabling "nounset" mode to start looking into the above bash-completion issue. Quick testing with zsh revealed the same issue with null $BASH_VERSION, and you found the $short_sha one.

Previous: Junio C Hamano
Message 3 of 3 in “git-prompt.sh: Don't error on null ${ZSH,BASH}_VERSION, $short_sha”
  1. 1/2 git-prompt.sh: Don't error on null ${ZSH,BASH}_VERSION, $short_shaVille Skyttä, Jun 6, 2016
  2. Junio C HamanoJun 6, 2016
  3. Ville SkyttäJun 7, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.