{"thread":{"id":"24564","subject":"[PATCH] bash-completion: Print a useful error when called in a non-bash shell","startedAt":"2010-07-28T22:32:37Z","lastAt":"2010-08-06T21:31:38Z","messageCount":8,"participants":["Andrew Sayers","Junio C Hamano","solsTiCe d'Hiver","Ævar Arnfjörð Bjarmason","Stephen Boyd","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"146660","messageId":"4C50B005.1030004@pileofstuff.org","threadId":"24564","inReplyTo":null,"subject":"[PATCH] bash-completion: Print a useful error when called in a non-bash shell","fromName":"Andrew Sayers","fromEmail":"andrew-git@pileofstuff.org","sentAt":"2010-07-28T22:32:37Z","receivedAt":"2010-07-28T22:32:37Z","isPatch":true,"sender":{"key":"andrew-git@pileofstuff.org","avatar":null},"body":"Detect whether the shell supports process substitution with <()\nShells that fail the test will not be able to load git-completion.bash\n\nIf a bad shell is found, print a warning which gives the user as much debugging\ninformation as possible.\n\nThis was added in response to a bug report on the git mailing list:\n  http://permalink.gmane.org/gmane.comp.version-control.git/151723\n\nSigned-off-by: Andrew Sayers <andrew-git@pileofstuff.org>\n---\n\nMy thanks to solsTiCe d'Hiver for reporting this bug.\n\n contrib/completion/git-completion.bash |   25 +++++++++++++++++++++++++\n 1 files changed, 25 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 6756990..3bbb4da 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -96,6 +96,31 @@ __gitdir ()\n \tfi\n }\n \n+# Check in case we were called with something like \"sh git-completion.bash\":\n+$(\n+\texec 2>/dev/null\n+\t$(exec < <( ))\n+ )\n+if [[ 0 -ne $? ]]\n+then\n+\tcat <<EOF\n+\n+ERROR: you don't seem to be running a full bash shell.\n+git-completion.bash is probably about to fail with a syntax error.\n+If you are sure that your system is calling git-completion.bash from a bash,\n+then please include the following in a bug report to git@vger.kernel.org:\n+\n+\tBASH_VERSION: {$BASH_VERSION}\n+\tBASHOPTS: {$BASHOPTS}\n+\tSHELLOPTS: {$SHELLOPTS}\n+\tPOSIXLY_CORRECT: {$POSIXLY_CORRECT}\n+EOF\n+\techo -n \"\tcommand line: {\"\n+\ttr '\\0' ' ' < /proc/$$/cmdline\n+\techo \"}\"\n+\techo\n+fi\n+\n # stores the divergence from upstream in $p\n # used by GIT_PS1_SHOWUPSTREAM\n __git_ps1_show_upstream ()\n-- \n1.7.0.4\n"},{"id":"146721","messageId":"7v4ofiuuf7.fsf@alter.siamese.dyndns.org","threadId":"24564","inReplyTo":"4C50B005.1030004@pileofstuff.org","subject":"Re: [PATCH] bash-completion: Print a useful error when called in a non-bash shell","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-07-29T16:25:32Z","receivedAt":"2010-07-29T16:25:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andrew Sayers <andrew-git@pileofstuff.org> writes:\n\n> Detect whether the shell supports process substitution with <()\n> Shells that fail the test will not be able to load git-completion.bash\n>\n> If a bad shell is found, print a warning which gives the user as much debugging\n> information as possible.\n>\n> This was added in response to a bug report on the git mailing list:\n>   http://permalink.gmane.org/gmane.comp.version-control.git/151723\n>\n> Signed-off-by: Andrew Sayers <andrew-git@pileofstuff.org>\n> ---\n\n> +# Check in case we were called with something like \"sh git-completion.bash\":\n> +$(\n> +\texec 2>/dev/null\n> +\t$(exec < <( ))\n> + )\n> +if [[ 0 -ne $? ]]\n> +then\n> +\tcat <<EOF\n> +\n> +ERROR: you don't seem to be running a full bash shell.\n> +git-completion.bash is probably about to fail with a syntax error.\n> +If you are sure that your system is calling git-completion.bash from a bash,\n> +then please include the following in a bug report to git@vger.kernel.org:\n\nI needed to read this twice to realize that majority of people who will\never see this message on their screen are _not_ expected to send any bug\nreport to us.  Also if the user's \"full bash\" groks <() indirection but\nstill fails to run completion script correctly, this message does not help\nthem to find where to file a bug report at all.\n\nI do agree that there need to be a way to find that information for the\nend users, especially for those who just use binary-packaged git given by\ntheir distros, but this codepath is _not_ the place to do it.\n\nHow about replacing these with something simple like:\n\n    echo >&2 \"You are not running full 'bash'; exiting.\" ; exit 127\n\n> +\tBASH_VERSION: {$BASH_VERSION}\n> +\tBASHOPTS: {$BASHOPTS}\n> +\tSHELLOPTS: {$SHELLOPTS}\n> +\tPOSIXLY_CORRECT: {$POSIXLY_CORRECT}\n> +EOF\n> +\techo -n \"\tcommand line: {\"\n> +\ttr '\\0' ' ' < /proc/$$/cmdline\n\nThis looks like a Linux-ism to me.\n"},{"id":"146729","messageId":"1280430307.2228.5.camel@soho.example.org","threadId":"24564","inReplyTo":"7v4ofiuuf7.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] bash-completion: Print a useful error when called in a non-bash shell","fromName":"solsTiCe d'Hiver","fromEmail":"solstice.dhiver@gmail.com","sentAt":"2010-07-29T19:05:07Z","receivedAt":"2010-07-29T19:05:07Z","isPatch":true,"sender":{"key":"solstice.dhiver@gmail.com","avatar":"https://gravatar.com/avatar/8f39aac7a4171412da9071838ca49808ba46c5da4b7cb51d0293f5289e8b4cec?d=mp&s=160"},"body":"I must re-emphasize that the bug was an archlinux bug in /etc/profile.\nhttp://bugs.archlinux.org/task/20288\n\nHaving said that, I don't see why you're trying to do anything about\nthat.\nIf I were you, I wouldn't bother to try to print any message at all.\n"},{"id":"146735","messageId":"4C51F2C0.8090101@pileofstuff.org","threadId":"24564","inReplyTo":"7v4ofiuuf7.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] bash-completion: Print a useful error when called in a non-bash shell","fromName":"Andrew Sayers","fromEmail":"andrew-git@pileofstuff.org","sentAt":"2010-07-29T21:29:36Z","receivedAt":"2010-07-29T21:29:36Z","isPatch":true,"sender":{"key":"andrew-git@pileofstuff.org","avatar":null},"body":"On 29/07/10 17:25, Junio C Hamano wrote:\n> \n> I do agree that there need to be a way to find that information for the\n> end users, especially for those who just use binary-packaged git given by\n> their distros, but this codepath is _not_ the place to do it.\n> \n> How about replacing these with something simple like:\n> \n>     echo >&2 \"You are not running full 'bash'; exiting.\" ; exit 127\n\nI take your point that this is not the place to advertise the mailing\nlist, although I prefer to include instructions in error messages.\nWould you be amenable in principle to creating something like `man\ngit-bug`?  A quick search doesn't turn up any documents specifically\nabout bug fixing/reporting, and a man page was the first place I thought\nto look.  I'll happily withdraw this patch until I can have a crack at\nsuch a page.\n\n>> +\tBASH_VERSION: {$BASH_VERSION}\n>> +\tBASHOPTS: {$BASHOPTS}\n>> +\tSHELLOPTS: {$SHELLOPTS}\n>> +\tPOSIXLY_CORRECT: {$POSIXLY_CORRECT}\n>> +EOF\n>> +\techo -n \"\tcommand line: {\"\n>> +\ttr '\\0' ' ' < /proc/$$/cmdline\n> \n> This looks like a Linux-ism to me.\n\nCaught red-flippered :)  I'll use `ps` next time.\n\n\t- Andrew\n"},{"id":"146740","messageId":"AANLkTikxNe-+tjHkxCk-FtRxLpeyRkx-Wx109iuE+6fL@mail.gmail.com","threadId":"24564","inReplyTo":"4C51F2C0.8090101@pileofstuff.org","subject":"Re: [PATCH] bash-completion: Print a useful error when called in a non-bash shell","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-07-29T22:16:15Z","receivedAt":"2010-07-29T22:16:15Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Thu, Jul 29, 2010 at 21:29, Andrew Sayers <andrew-git@pileofstuff.org> wrote:\n\n> On 29/07/10 17:25, Junio C Hamano wrote:\n>> This looks like a Linux-ism to me.\n>\n> Caught red-flippered :)  I'll use `ps` next time.\n\nThat's also probably hard to get right on all the mutually\nincompatible *nix ps(1) implementations out there.\n\nAs for this patch in general, I think solving this issue in Git's\nbash-completion code isn't the right thing to do, I think the right\nthing is to just ignore it and no nothing.\n\nAny given *nix distribution will include lots of non-POSIX and\nshell-specific initialization files throughout the system. Trying to\ndetect if the shell is running in POSIX compatibility mode in each of\nthese is going to be redundant and bug-prone.\n\nInstead the user should make sure that he's invoking the shell in\nnon-POSIX mode before evaluating non-POSIX code.\n\nMaybe this is a bigger potential problem than it seems, but it seems\nlike just a one-off error in Arch Linux. I'd be surprised if it didn't\nalso break dozens of other packages in Arch which included bash\nextensions.\n\nThis is not a nack, if you want to pursue this and try to emit a\nfriendlier error message that's great. But maybe it's a bit *too* much\neffort on our part.\n"},{"id":"146746","messageId":"7vr5ilsvtf.fsf@alter.siamese.dyndns.org","threadId":"24564","inReplyTo":"4C51F2C0.8090101@pileofstuff.org","subject":"Re: [PATCH] bash-completion: Print a useful error when called in a non-bash shell","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-07-29T23:38:20Z","receivedAt":"2010-07-29T23:38:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andrew Sayers <andrew-git@pileofstuff.org> writes:\n\n> Would you be amenable in principle to creating something like `man\n> git-bug`?  A quick search doesn't turn up any documents specifically\n> about bug fixing/reporting, and a man page was the first place I thought\n> to look.\n\nI'd be perfectly fine with something like this.  People may want to add a\nsentence or two to give tips on how to make sure that they are actual\nbugs.\n\n\n Documentation/git.txt |    8 ++++++++\n 1 files changed, 8 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex 59f291d..3ba004f 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -727,6 +727,14 @@ The documentation for git suite was started by David Greaves\n <david@dgreaves.com>, and later enhanced greatly by the\n contributors on the git-list <git@vger.kernel.org>.\n \n+Reporting Bugs\n+--------------\n+\n+If you found a bug, please send a bug report to the Git mailing list\n+<git@vger.kernel.org>, where the development and maintenance is primarily\n+done.  You do not have to be subscribed to the list to send a message\n+there.\n+\n SEE ALSO\n --------\n linkgit:gittutorial[7], linkgit:gittutorial-2[7],\n"},{"id":"146755","messageId":"4C526AF1.8000309@gmail.com","threadId":"24564","inReplyTo":"7vr5ilsvtf.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] bash-completion: Print a useful error when called in a non-bash shell","fromName":"Stephen Boyd","fromEmail":"bebarino@gmail.com","sentAt":"2010-07-30T06:02:25Z","receivedAt":"2010-07-30T06:02:25Z","isPatch":true,"sender":{"key":"bebarino@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"  On 07/29/2010 04:38 PM, Junio C Hamano wrote:\n>\n> +Reporting Bugs\n> +--------------\n> +\n> +If you found a bug, please send a bug report to the Git mailing list\n> +<git@vger.kernel.org>, where the development and maintenance is primarily\n> +done.  You do not have to be subscribed to the list to send a message\n> +there.\n> +\n\nI like it. How do I know if I found a bug though? Probably better to just say:\n\n\tReport bugs to the Git mailing list<git@vger.kernel.org>\n\twhere development and ...\n"},{"id":"147351","messageId":"201008062331.38279.j6t@kdbg.org","threadId":"24564","inReplyTo":"4C50B005.1030004@pileofstuff.org","subject":"Re: [PATCH] bash-completion: Print a useful error when called in a non-bash shell","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-08-06T21:31:38Z","receivedAt":"2010-08-06T21:31:38Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Donnerstag, 29. Juli 2010, Andrew Sayers wrote:\n> Detect whether the shell supports process substitution with <()\n> Shells that fail the test will not be able to load git-completion.bash\n>\n> If a bad shell is found, print a warning which gives the user as much\n> debugging information as possible.\n\nThis cannot work the way you implemented it:\n\n> +$( \n> +\texec 2>/dev/null\n> +\t$(exec < <( ))\n> + )\n\nAny shell that does not support the <() syntax will have exited at this time \nwith a syntax error and never get to print something.\n\nThis could work:\n\n  (eval : '$(exec < <( ) )' 2>/dev/null)\n\n> +if [[ 0 -ne $? ]]\n\nOf course, you must not use unportable [[ ]] syntax here, either.\n\n> +then\n> +\tcat <<EOF\n> ...\n\n-- Hannes\n"}]}