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 "$@"
> + fiI think an unconditional
echo >&2 "$*"
is good enough here.
> + exit $stat > } > > GIT_QUIET=