All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Elia Pinto <gitter.spiros@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status
Date: Wed, 23 Mar 2022 04:13:05 -0700	[thread overview]
Message-ID: <xmqqsfr8udku.fsf@gitster.g> (raw)
In-Reply-To: 220322.86r16unzer.gmgdl@evledraar.gmail.com

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> We also document for some of these programs that on failure we'll
> return 1 specifically, not whatever EXIT_FAILURE is.

I view this as a real issue.  EXIT_FAILURE could by happenstance be
defined to be the same value on all platforms we care about, but if
it leaves the possibility that the next major thing will break our
assumption, I do not see much point in adopting it.  Whole-sale
rewriting of 0 and 1 to EXIT_SUCCESS and EXIT_FAILURE smells like
adopting a bad standardization without thinking things through, only
for the sake of adopting "standardization".

> ... but we should fix the exit(-1) cases, and that's best done
> with some new GIT_TEST_ASSERT_NO_UNPORTABLE_EXIT testing or
> whatever.

That is probably a good #leftoverbit, even a candidate for future
#microprojects.

> I think we'd be much better off with something like this in
> git-compat-util.h:
>
>     #ifndef BYPASS_EXIT_SANITY
>     #ifdef EXIT_SUCCESS
>     #if EXIT_SUCCESS != 0
>     #error "git assumes EXIT_SUCCESS is 0, not whatever yours is, please report this. Build with -DBYPASS_EXIT_SANITY to continue building at your own risk"

This is not a good idea.  EXIT_SUCCESS does not have to be literally
0.  It only has to be a value that causes the process to exit with 0
when passed to exit().

>     #endif
>     #endif
>     #ifdef EXIT_FAILURE
>     #if EXIT_FAILURE != 0

I think you meant "!= 1".  If we were to take these 41 patches, we
must have this hunk, as we want our plumbing tools to be drivable by
shell scripts, i.e. 

	git foo ||
	case $? in
	1) # generic failure
		...
	esac

and we do not want to be forced to write something like

	. git-stdlib-util.sh ;# for platform-dependent $EXIT_FAILURE

	...
	git foo ||
	case $? in
	$EXIT_FAILURE) # generic failure
		...
	esac
	
instead.

      parent reply	other threads:[~2022-03-23 11:13 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21 22:54 [PATCH 00/41] use the stdlib EXIT_SUCCESS or EXIT_FAILURE exit status Elia Pinto
2022-03-21 22:54 ` [PATCH 01/41] archive.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 02/41] branch.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 03/41] am.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 04/41] blame.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 05/41] commit.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 06/41] credential-cache--daemon.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 07/41] help.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 08/41] init-db.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 09/41] mailsplit.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 10/41] merge-index.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 11/41] merge.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 12/41] pull.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 13/41] rebase.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 14/41] remote-ext.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 15/41] rev-parse.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 16/41] rm.c: " Elia Pinto
2022-03-21 22:54 ` [PATCH 17/41] shortlog.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 18/41] show-branch.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 19/41] stash.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 20/41] tag.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 21/41] unpack-objects.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 22/41] update-index.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 23/41] obstack.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 24/41] git-credential-osxkeychain.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 25/41] git-credential-wincred.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 26/41] daemon.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 27/41] git.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 28/41] help.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 29/41] http-backend.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 30/41] parse-options.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 31/41] path.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 32/41] remote-curl.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 33/41] run-command.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 34/41] setup.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 35/41] shell.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 36/41] test-json-writer.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 37/41] test-reach.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 38/41] test-submodule-config.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 39/41] test-submodule-nested-repo-config.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 40/41] upload-pack.c: " Elia Pinto
2022-03-21 22:55 ` [PATCH 41/41] exit.cocci: " Elia Pinto
2022-03-22  6:49 ` [PATCH 00/41] " Bagas Sanjaya
2022-03-22  8:45   ` Elia Pinto
2022-03-22 11:21   ` Bagas Sanjaya
2022-03-22  8:26 ` Ævar Arnfjörð Bjarmason
2022-03-22 17:47   ` Elia Pinto
2022-03-23 11:13   ` 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=xmqqsfr8udku.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitter.spiros@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.