git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ville Skyttä" <ville.skytta@iki.fi>
Cc: "Shawn O. Pearce" <spearce@spearce.org>, git@vger.kernel.org
Subject: Re: [PATCH] Abort early if not being sourced under bash.
Date: Fri, 08 Feb 2008 13:31:08 -0800	[thread overview]
Message-ID: <7vprv7i19f.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <200802082310.34398.ville.skytta@iki.fi> (Ville Skyttä's message of "Fri, 8 Feb 2008 23:10:34 +0200")

Ville Skyttä <ville.skytta@iki.fi> writes:

> Subject: [PATCH] Abort early if not being sourced under bash.
>
> This way, the file can be safely sourced from profile files shared with
> non-bash shells, eg. dropped into /etc/profile.d like directories.
>
> Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
> ---
>  contrib/completion/git-completion.bash |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 4ea727b..3cde9f4 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -45,6 +45,8 @@
>  #       git@vger.kernel.org
>  #
>  
> +[ -z "$BASH_VERSION" ] && return
> +
>  __gitdir ()
>  {
>  	if [ -z "$1" ]; then

I do not particularly sympathize with the /etc/profile.d/
argument.  Ditros can and should put a small script in there
that checks what /bin/sh it really is running and source the
real thing from elsewhere, perhaps /usr/share/git-core/,
appropriately.

However, even if you did so, there is another issue.  One of my
hosts have a bash that does not know the "complete" command, and
logging into the host I get twenty-or-so "bash: complete:
command not found".

So

	if bash "complete" would not work for this shell
        then
        	__git_ps1 () { : dummy; }
		return
	fi

at the beginning may be needed even if you know we are running
bash.

Then people can safely say:

	PS1=': \h \W$(__git_ps1 "/%s"); '

(or whatever git-completion.bash suggests these days) in their
start-up script.

      parent reply	other threads:[~2008-02-08 21:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-08 21:10 [PATCH] Abort early if not being sourced under bash Ville Skyttä
2008-02-08 21:14 ` Johannes Schindelin
2008-02-08 21:31 ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vprv7i19f.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    --cc=ville.skytta@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).