1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
package prep
// Gemini's excellent at this sorta research. Not much else though
// This file defines a set of conventional exit codes for command-line applications,
// based on the BSD `sysexits.h` standard and common GNU/Linux practices.
// Using these constants makes the program's exit behavior clear and consistent.
// ExitCode represents a program's exit status code.
type ExitCode int
const (
// --- Standard Success/Failure ---
// ExitSuccess indicates that the program completed its task without errors.
ExitSuccess ExitCode = 0
// ExitFailure is a generic, catch-all code for "something went wrong."
// It should be used if no other more specific code applies.
ExitFailure ExitCode = 1
// --- Errors based on BSD sysexits.h ---
// ExitUsage indicates that the user provided invalid command-line arguments or flags.
// (Standard: EX_USAGE)
ExitUsage ExitCode = 64
// ExitDataErr indicates that the input data was incorrect or malformed.
// (e.g., a corrupt configuration file).
// (Standard: EX_DATAERR)
ExitDataErr ExitCode = 65
// ExitNoInput indicates that an input file was not found or could not be read.
// (Standard: EX_NOINPUT)
ExitNoInput ExitCode = 66
// ExitNoUser indicates that a specified user did not exist.
// (Standard: EX_NOUSER)
ExitNoUser ExitCode = 67
// ExitNoHost indicates that a specified host did not exist.
// (Standard: EX_NOHOST)
ExitNoHost ExitCode = 68
// ExitUnavailable indicates that a required service is unavailable.
// (Standard: EX_UNAVAILABLE)
ExitUnavailable ExitCode = 69
// ExitSoftware indicates an internal software error. This is for unexpected
// conditions and bugs ("this should never happen").
// (Standard: EX_SOFTWARE)
ExitSoftware ExitCode = 70
// ExitOSErr indicates an operating system error, such as a failed system call.
// (e.g., fork failed, couldn't create a directory).
// (Standard: EX_OSERR)
ExitOSErr ExitCode = 71
// ExitOSFile indicates a critical OS file is missing or corrupt.
// (e.g., /etc/passwd).
// (Standard: EX_OSFILE)
ExitOSFile ExitCode = 72
// ExitCantCreat indicates that a user-specified output file could not be created.
// (Standard: EX_CANTCREAT)
ExitCantCreat ExitCode = 73
// ExitIOErr indicates an error occurred during an I/O operation.
// (Standard: EX_IOERR)
ExitIOErr ExitCode = 74
// ExitTempFail indicates a temporary failure. The user is invited to retry.
// (Standard: EX_TEMPFAIL)
ExitTempFail ExitCode = 75
// ExitProtocol indicates a protocol error during network communication.
// (Standard: EX_PROTOCOL)
ExitProtocol ExitCode = 76
// ExitNoPerm indicates that the user does not have sufficient permissions.
// This is for filesystem permissions, not for authentication issues.
// (Standard: EX_NOPERM)
ExitNoPerm ExitCode = 77
// ExitConfig indicates that something is wrong in a configuration file.
// (Standard: EX_CONFIG)
ExitConfig ExitCode = 78
)
// Note: Exit codes 126, 127, and >128 are reserved for the shell to indicate
// specific execution failures (command not executable, command not found, or
// termination by a signal) and should not be used by applications.
|