git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Fredrik Gustafsson <iveqy@iveqy.com>
Cc: hvoigt@hvoigt.net, jens.lehmann@web.de, git@vger.kernel.org
Subject: Re: [PATCH v3 1/2] Add new function die_with_status
Date: Mon, 13 Jun 2011 11:07:03 -0700	[thread overview]
Message-ID: <7vd3ihobaw.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1307605623-2831-2-git-send-email-iveqy@iveqy.com> (Fredrik Gustafsson's message of "Thu, 9 Jun 2011 09:47:02 +0200")

Fredrik Gustafsson <iveqy@iveqy.com> writes:

> die no longer prints empty die messages, this is a changed behavior.

That is what we we usually call a regression, but I think the original is
not correct to begin with.  It should have used "$*" not "$@".

> diff --git a/git-sh-setup.sh b/git-sh-setup.sh
> index 94e26ed..1a91f6e 100644
> --- a/git-sh-setup.sh
> +++ b/git-sh-setup.sh
> @@ -40,8 +40,16 @@ git_broken_path_fix () {
>  # @@BROKEN_PATH_FIX@@
>  
>  die() {
> -	echo >&2 "$@"
> -	exit 1
> +	die_with_status 1 $@

Make it a habit to always quote "$@" when relaying what was given to you,
so that when somebody sends a parameter with IFS in it, you won't split it
while passing it down. I.e.

	die () {
        	die_with_status 1 "$@"
	}

> +}

Blank line here after the closing brace and the beginning of next function.

> +die_with_status() {
> +	stat=$1
> +	shift
> +	if test ${#@} -gt 0
> +	then
> +		echo >&2 "$@"
> +	fi

I think an unconditional

	echo >&2 "$*"

is good enough here.

> +	exit $stat
>  }
>  
>  GIT_QUIET=

  reply	other threads:[~2011-06-13 18:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-09  7:47 [PATCH v3 0/2] submodule update continue Fredrik Gustafsson
2011-06-09  7:47 ` [PATCH v3 1/2] Add new function die_with_status Fredrik Gustafsson
2011-06-13 18:07   ` Junio C Hamano [this message]
2011-06-09  7:47 ` [PATCH v3 2/2] submodule update: continue when a checkout fails Fredrik Gustafsson
2011-06-09 17:21   ` Junio C Hamano
2011-06-13 17:15     ` [PATCH v4 " Fredrik Gustafsson

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=7vd3ihobaw.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=hvoigt@hvoigt.net \
    --cc=iveqy@iveqy.com \
    --cc=jens.lehmann@web.de \
    /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).