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

Re: [Leftoverbits] exit code clean-up?

From
Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Date
Aug 17, 2023, 09:24 UTC
Message-ID
<ZN3nSsGOHMDQZ438@ugly>
In-Reply-To
<xmqqsf8iex5v.fsf_-_@gitster.g>
On Wed, Aug 16, 2023 at 10:04:28AM -0700, Junio C Hamano wrote:
Show 5 quoted lines
>"git help git" does not have "EXIT CODES" section, and it is assumed 
>that the "common sense" of older generation [...] that exiting with 0 
>is success and non-zero is failure is shared among its users, which 
>might not be warranted these days.
>

well, that's actually a standard (exit(3) has things to say about it), and given how shell scripts treat exit codes, there is no wiggle room here. just about every shell intro tutorial explains it.

Show 14 quoted lines
>We could either
>
> * Be more prescriptive and add "EXIT CODES" section to each and
>   every document to describe how we fail in the current code.
>
>or
>
> * Describe "In general, 0 is success, non-zero is failure, but some
>   commands may signal more than that with its non-zero exit codes"
>   in "git help git", and add "EXIT CODES" section to the manual
>   page of the commands whose exit codes matter (there are a
>   handful, like "git diff --exit-code" that explicitly says "1" is
>   the signal that it found difference as opposed to it failing).
>
i'd go with the second, with some minor modifications:
- 1 is the by far most common non-zero error code (and it matches 
   EXIT_FAILURE on all relevant systems), so it's ok to state that. it 
   may be wise to actually check that commands don't deviate from it 
   needlessly.
- the canonical name of the section appears to be "EXIT STATUS"
regards
Previous: Junio C HamanoNext: Junio C Hamano
Message 10 of 12 in “upload-pack: fix race condition in error messages”
  1. upload-pack: fix race condition in error messagesDerrick Stolee via GitGitGadget, Aug 10, 2023
  2. Junio C HamanoAug 10, 2023
  3. upload-pack: fix exit code when denying fetch of unreachable object IDPatrick Steinhardt, Aug 16, 2023
  4. Junio C HamanoAug 16, 2023
  5. Junio C HamanoAug 16, 2023
  6. Jeff KingAug 17, 2023
  7. [Leftoverbits] exit code clean-up?Junio C Hamano, Aug 16, 2023
  8. Jeff KingAug 17, 2023
  9. Junio C HamanoAug 17, 2023
  10. Oswald BuddenhagenAug 17, 2023
  11. Junio C HamanoAug 17, 2023
  12. Patrick SteinhardtAug 17, 2023

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.