git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 1/2] Add new function die_with_status

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 13, 2011, 18:07 UTC
Message-ID
<7vd3ihobaw.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1307605623-2831-2-git-send-email-iveqy@iveqy.com>
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 "$@".

Show 11 quoted lines
> 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.
Show 7 quoted lines
> +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=
Previous: Fredrik GustafssonNext: Fredrik Gustafsson
Message 3 of 6 in “submodule update continue”
  1. 0/2 submodule update continueFredrik Gustafsson, Jun 9, 2011
  2. 1/2 Add new function die_with_statusFredrik Gustafsson, Jun 9, 2011
  3. Junio C HamanoJun 13, 2011
  4. 2/2 submodule update: continue when a checkout failsFredrik Gustafsson, Jun 9, 2011
  5. Junio C HamanoJun 9, 2011
  6. 2/2 submodule update: continue when a checkout failsFredrik Gustafsson, Jun 13, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.