Skip to content

Exit statuses follow Graphviz's dot: 2 for an unreadable input, 1 for a bad command line - #158

Merged
closer-claudio merged 1 commit into
mainfrom
claudio/20261122-statuses
Nov 23, 2026
Merged

closer-claudio merged 1 commit into
mainfrom
claudio/20261122-statuses

Conversation

@closer-claudio

@closer-claudio closer-claudio commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Breaking: the exit statuses of a failure change. A script that tests for 2 to detect a usage error, or 1 for a missing input, has to follow.

The command had statuses of its own (1 for an input or rendering error, 2 for a usage error). Graphviz's dot, which this command stands in for, has them the other way round. Run beside Graphviz's dot 16.1.1:

Case Graphviz before now
a file that is not there 2 1 2
a file that may not be opened 2 1 2
an empty name (dot "") 2 standard input was read 2
an unknown flag (-Q) 1 2 1
an unknown format, an unknown layout 1 2 1
-T, -K or -o without its value 1 2 1
a directory as the input 0, silent 1 2
two inputs renders both 2 1

run returns 2 when the input cannot be read and 1 for every other failure. A command line it cannot take still gets the usage on standard error. A parse error, a failed render, an output that cannot be written and an error Graphviz reports while it draws were 1 and stay 1, as with Graphviz's dot.

An empty argument, which an unset variable gives a script, was taken for no input at all. It is now a name like another, of a file that cannot be opened.

Two differences are kept on purpose, and the README now says them:

  • A directory as the input stays an error, with the status of an input that cannot be read. Graphviz's dot opens it, reads nothing, says nothing and exits 0, which tells a caller that named the wrong path that all went well.
  • - stays standard input. Graphviz's dot refuses it as an unknown option, so accepting it takes nothing away.

Tests: TestFailuresExitAsGraphvizsDot holds each status that follows the reference, ten cases, and each is also run against the native dot when DOT_ORACLE names one (all ten pass against 16.1.1). The table of TestExitStatusesAndStreams carries the new statuses, the directory among them. FuzzInput's contract (0 or 1 for any bytes on standard input) is unchanged: 2 needs an input that cannot be read.

Not here: the command still takes one input file where Graphviz's dot renders several. And an input that holds several graphs is rendered in part, a later syntax error exiting 0 where Graphviz's dot exits 1: #159.

… a bad command line

The command had statuses of its own: 1 for an input or rendering error, 2
for a usage error. Graphviz's dot, which the command stands in for, has
them the other way round, so a script that tells the two apart read each
for the other. Run beside dot 16.1.1:

                                  Graphviz   before   now
  a file that is not there            2         1      2
  a file that may not be opened       2         1      2
  an empty name (dot "")              2      (stdin)   2
  an unknown flag (-Q)                1         2      1
  an unknown format, an unknown layout 1        2      1
  -T, -K or -o without its value      1         2      1
  a directory as the input            0         1      2
  two inputs                       (renders)    2      1

run now returns 2 when the input cannot be read and 1 for every other
failure; a command line it cannot take still gets the usage on standard
error. A parse error, a failed render, an output that cannot be written
and an error Graphviz reports while it draws were 1 and stay 1, as there.

An empty argument, which an unset variable gives a script, was taken for
no input at all and standard input was read. It is a name like another,
of a file that cannot be opened: the options record that an input was
named, apart from what the name is.

Two differences are kept on purpose and said in the README. A directory as the
input stays an error, now with the status of an input that cannot be read:
Graphviz's dot opens it, reads nothing, says nothing and exits 0, which
tells a caller that named the wrong path that all went well. "-" stays
standard input, which Graphviz's dot refuses as an unknown option: it
takes nothing away from what that command accepts.

TestFailuresExitAsGraphvizsDot holds each status that follows the
reference to the native dot when DOT_ORACLE names one (ten cases, each
run against dot 16.1.1 here, a graph waiting on standard input in each);
the table of TestExitStatusesAndStreams carries the new statuses, the
directory among them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: closer-claudio <claudio@farcloser.world>
@closer-claudio closer-claudio added the breaking Breaks a consumer label Nov 23, 2026
@closer-claudio

Copy link
Copy Markdown
Contributor Author

Reviewed at 798d34e

@closer-claudio
closer-claudio merged commit f74452f into main Nov 23, 2026
14 checks passed
@closer-claudio
closer-claudio deleted the claudio/20261122-statuses branch November 23, 2026 06:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaks a consumer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants