Skip to content

Exit codes don't match help text #7296

@sim642

Description

@sim642

Expected Behavior

dune --help output says:

EXIT STATUS
       dune exits with the following status:

       0   on success.

       123 on indiscriminate errors reported on standard error.

       124 on command line parsing errors.

       125 on unexpected internal errors (bugs).

This is the default from Cmdliner.

Actual Behavior

Possible exit codes are 0, 1 and 130:

dune/bin/main.ml

Lines 90 to 106 in 449cbd3

let exit_and_flush code =
Console.finish ();
exit code
let () =
Dune_rules.Colors.setup_err_formatter_colors ();
try
match Cmd.eval_value cmd ~catch:false with
| Ok _ -> exit_and_flush 0
| Error _ -> exit_and_flush 1
with
| Scheduler.Run.Shutdown.E Requested -> exit_and_flush 0
| Scheduler.Run.Shutdown.E (Signal _) -> exit_and_flush 130
| exn ->
let exn = Exn_with_backtrace.capture exn in
Dune_util.Report_error.report exn;
exit_and_flush 1

Reproduction

  1. Run dune with invalid arguments: dune --foo.
  2. Check exit code: echo $? – currently outputs 1, not 124.

Specifications

  • Version of dune (output of dune --version): 3.7.0
  • Version of ocaml (output of ocamlc --version): 4.14.0
  • Operating system (distribution and version): Xubuntu 22.04.2

Metadata

Metadata

Assignees

Labels

docsDocumentation improvements

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions