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

Re: [PATCH] bash-completion: Print a useful error when called in a non-bash shell

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 29, 2010, 16:25 UTC
Message-ID
<7v4ofiuuf7.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4C50B005.1030004@pileofstuff.org>
Andrew Sayers <andrew-git@pileofstuff.org> writes:
Show 11 quoted lines
> Detect whether the shell supports process substitution with <()
> Shells that fail the test will not be able to load git-completion.bash
>
> If a bad shell is found, print a warning which gives the user as much debugging
> information as possible.
>
> This was added in response to a bug report on the git mailing list:
>   http://permalink.gmane.org/gmane.comp.version-control.git/151723
>
> Signed-off-by: Andrew Sayers <andrew-git@pileofstuff.org>
> ---
Show 13 quoted lines
> +# Check in case we were called with something like "sh git-completion.bash":
> +$(
> +	exec 2>/dev/null
> +	$(exec < <( ))
> + )
> +if [[ 0 -ne $? ]]
> +then
> +	cat <<EOF
> +
> +ERROR: you don't seem to be running a full bash shell.
> +git-completion.bash is probably about to fail with a syntax error.
> +If you are sure that your system is calling git-completion.bash from a bash,
> +then please include the following in a bug report to git@vger.kernel.org:

I needed to read this twice to realize that majority of people who will ever see this message on their screen are _not_ expected to send any bug report to us. Also if the user's "full bash" groks <() indirection but still fails to run completion script correctly, this message does not help them to find where to file a bug report at all.

I do agree that there need to be a way to find that information for the end users, especially for those who just use binary-packaged git given by their distros, but this codepath is _not_ the place to do it.

How about replacing these with something simple like:
    echo >&2 "You are not running full 'bash'; exiting." ; exit 127
Show 7 quoted lines
> +	BASH_VERSION: {$BASH_VERSION}
> +	BASHOPTS: {$BASHOPTS}
> +	SHELLOPTS: {$SHELLOPTS}
> +	POSIXLY_CORRECT: {$POSIXLY_CORRECT}
> +EOF
> +	echo -n "	command line: {"
> +	tr '\0' ' ' < /proc/$$/cmdline
This looks like a Linux-ism to me.
Previous: Andrew SayersNext: solsTiCe d'Hiver
Message 2 of 8 in “bash-completion: Print a useful error when called in a non-bash shell”
  1. bash-completion: Print a useful error when called in a non-bash shellAndrew Sayers, Jul 28, 2010
  2. Junio C HamanoJul 29, 2010
  3. solsTiCe d'HiverJul 29, 2010
  4. Andrew SayersJul 29, 2010
  5. Ævar Arnfjörð BjarmasonJul 29, 2010
  6. Junio C HamanoJul 29, 2010
  7. Stephen BoydJul 30, 2010
  8. Johannes SixtAug 6, 2010

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.