git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bash-completion: Print a useful error when called in a non-bash shell
@ 2010-07-28 22:32 Andrew Sayers
  2010-07-29 16:25 ` Junio C Hamano
  2010-08-06 21:31 ` Johannes Sixt
  0 siblings, 2 replies; 8+ messages in thread
From: Andrew Sayers @ 2010-07-28 22:32 UTC (permalink / raw)
  To: Git Mailing List; +Cc: solsTiCe d'Hiver

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>
---

My thanks to solsTiCe d'Hiver for reporting this bug.

 contrib/completion/git-completion.bash |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 6756990..3bbb4da 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -96,6 +96,31 @@ __gitdir ()
 	fi
 }
 
+# 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:
+
+	BASH_VERSION: {$BASH_VERSION}
+	BASHOPTS: {$BASHOPTS}
+	SHELLOPTS: {$SHELLOPTS}
+	POSIXLY_CORRECT: {$POSIXLY_CORRECT}
+EOF
+	echo -n "	command line: {"
+	tr '\0' ' ' < /proc/$$/cmdline
+	echo "}"
+	echo
+fi
+
 # stores the divergence from upstream in $p
 # used by GIT_PS1_SHOWUPSTREAM
 __git_ps1_show_upstream ()
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-08-06 21:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-28 22:32 [PATCH] bash-completion: Print a useful error when called in a non-bash shell Andrew Sayers
2010-07-29 16:25 ` Junio C Hamano
2010-07-29 19:05   ` solsTiCe d'Hiver
2010-07-29 21:29   ` Andrew Sayers
2010-07-29 22:16     ` Ævar Arnfjörð Bjarmason
2010-07-29 23:38     ` Junio C Hamano
2010-07-30  6:02       ` Stephen Boyd
2010-08-06 21:31 ` Johannes Sixt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).