{"thread":{"id":"11974","subject":"[PATCH] Abort early if not being sourced under bash.","startedAt":"2008-02-08T21:10:34Z","lastAt":"2008-02-08T21:31:08Z","messageCount":3,"participants":["Ville Skyttä","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"68002","messageId":"200802082310.34398.ville.skytta@iki.fi","threadId":"11974","inReplyTo":null,"subject":"[PATCH] Abort early if not being sourced under bash.","fromName":"Ville Skyttä","fromEmail":"ville.skytta@iki.fi","sentAt":"2008-02-08T21:10:34Z","receivedAt":"2008-02-08T21:10:34Z","isPatch":true,"sender":{"key":"ville.skytta@iki.fi","avatar":"https://avatars.githubusercontent.com/u/109152?v=4"},"body":"Subject: [PATCH] Abort early if not being sourced under bash.\n\nThis way, the file can be safely sourced from profile files shared with\nnon-bash shells, eg. dropped into /etc/profile.d like directories.\n\nSigned-off-by: Ville Skyttä <ville.skytta@iki.fi>\n---\n contrib/completion/git-completion.bash |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 4ea727b..3cde9f4 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -45,6 +45,8 @@\n #       git@vger.kernel.org\n #\n \n+[ -z \"$BASH_VERSION\" ] && return\n+\n __gitdir ()\n {\n \tif [ -z \"$1\" ]; then\n-- \n1.5.3.8\n"},{"id":"68003","messageId":"alpine.LSU.1.00.0802082113410.11591@racer.site","threadId":"11974","inReplyTo":"200802082310.34398.ville.skytta@iki.fi","subject":"Re: [PATCH] Abort early if not being sourced under bash.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-08T21:14:37Z","receivedAt":"2008-02-08T21:14:37Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 8 Feb 2008, Ville Skyttä wrote:\n\n> Subject: [PATCH] Abort early if not being sourced under bash.\n\nPlease do not repeat the subject.  And prepend \"git-completion: \" so \npeople can see from the subject already what this patch is about.\n\nAs for the patch, yeah, I think it should go in.\n\nCiao,\nDscho"},{"id":"68009","messageId":"7vprv7i19f.fsf@gitster.siamese.dyndns.org","threadId":"11974","inReplyTo":"200802082310.34398.ville.skytta@iki.fi","subject":"Re: [PATCH] Abort early if not being sourced under bash.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-08T21:31:08Z","receivedAt":"2008-02-08T21:31:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ville Skyttä <ville.skytta@iki.fi> writes:\n\n> Subject: [PATCH] Abort early if not being sourced under bash.\n>\n> This way, the file can be safely sourced from profile files shared with\n> non-bash shells, eg. dropped into /etc/profile.d like directories.\n>\n> Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>\n> ---\n>  contrib/completion/git-completion.bash |    2 ++\n>  1 files changed, 2 insertions(+), 0 deletions(-)\n>\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index 4ea727b..3cde9f4 100755\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -45,6 +45,8 @@\n>  #       git@vger.kernel.org\n>  #\n>  \n> +[ -z \"$BASH_VERSION\" ] && return\n> +\n>  __gitdir ()\n>  {\n>  \tif [ -z \"$1\" ]; then\n\nI do not particularly sympathize with the /etc/profile.d/\nargument.  Ditros can and should put a small script in there\nthat checks what /bin/sh it really is running and source the\nreal thing from elsewhere, perhaps /usr/share/git-core/,\nappropriately.\n\nHowever, even if you did so, there is another issue.  One of my\nhosts have a bash that does not know the \"complete\" command, and\nlogging into the host I get twenty-or-so \"bash: complete:\ncommand not found\".\n\nSo\n\n\tif bash \"complete\" would not work for this shell\n        then\n        \t__git_ps1 () { : dummy; }\n\t\treturn\n\tfi\n\nat the beginning may be needed even if you know we are running\nbash.\n\nThen people can safely say:\n\n\tPS1=': \\h \\W$(__git_ps1 \"/%s\"); '\n\n(or whatever git-completion.bash suggests these days) in their\nstart-up script.\n"}]}