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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fredrik Gustafsson <iveqy@xxxxxxxxx> 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=
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]