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

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

From
Ville Skyttä <ville.skytta@iki.fi>
Date
Jun 6, 2016, 16:31 UTC
Message-ID
<CABr9L5CQeL6iaTh-=G8sfWuygqgpj50mxBaOSL6ihS6x91F3UA@mail.gmail.com>
In-Reply-To
<xmqqshx75psw.fsf@gitster.mtv.corp.google.com>
On Tue, May 24, 2016 at 8:27 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 23 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.
>>       local ps1_expanded=yes
>> -     [ -z "$ZSH_VERSION" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no
>> -     [ -z "$BASH_VERSION" ] || shopt -q promptvars || ps1_expanded=no
>> +     [ -z "${ZSH_VERSION-}" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no
>> +     [ -z "${BASH_VERSION-}" ] || shopt -q promptvars || ps1_expanded=no
>
> I wonder if we can teach t9903 to run (at least) some parts of the
> completion script under "set -u" to catch these automatically without
> a report from an end user.
>
> With the attached "just started to scratch the surface" patch to
> test-lib.sh and fix by Ville to the git-prompt.sh script, we find
> another one.
>
>     ...contrib/completion/git-prompt.sh: line 481: short_sha: unbound variable
>
> Ville, I think you want to take the "git-prompt.sh" part from the
> following and replace it with your patch.

Hm, I'm not entirely sure what I was expected to do, but I took the short_sha bit, added it to my patch (modifying to be in line with the style of the rest of the file), and submitted a superseding patch with the subject "[PATCH 1/2] git-prompt.sh: Don't error on null ${ZSH,BASH}_VERSION, $short_sha" (and there's no part 2/2 coming, that was a user error).

Previous: Junio C Hamano
Message 5 of 5 in “git-prompt.sh: Don't error on null ${ZSH,BASH}_VERSION”
  1. git-prompt.sh: Don't error on null ${ZSH,BASH}_VERSIONVille Skyttä, May 24, 2016
  2. Junio C HamanoMay 24, 2016
  3. Junio C HamanoMay 24, 2016
  4. Junio C HamanoMay 24, 2016
  5. Ville SkyttäJun 6, 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.