Skip to content

Commit 519c36a

Browse files
committed
console compiler: revamp exit codes
Don't use -1 since that is turned into 255 on unix systems. Small non-negative integers should work on all platforms. 0 = success 1 = unexpected error 2 = usage error 3 = serious warnings (controlled by flag)
1 parent 7248117 commit 519c36a

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

sources/environment/commands/build.dylan

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,13 @@ define method do-execute-command
265265
end;
266266
message(context, "Build of '%s' completed", project.project-name);
267267
if (serious-warnings? & ~command.%allow-serious-warnings?)
268-
$error-exit-code
268+
$serious-warnings-exit-code
269269
else
270270
$success-exit-code
271271
end
272272
else
273273
message(context, "Build of '%s' aborted", project.project-name);
274-
$error-exit-code
274+
$unexpected-error-exit-code
275275
end
276276
exception (error :: <file-system-error>)
277277
command-error("%s", error)

sources/environment/commands/command-line.dylan

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ Warranty: Distributed WITHOUT WARRANTY OF ANY KIND
88

99
/// Useful constants
1010

11-
define constant $success-exit-code = 0;
12-
define constant $error-exit-code = -1;
11+
define constant $success-exit-code = 0;
12+
define constant $unexpected-error-exit-code = 1;
13+
define constant $usage-error-exit-code = 2;
14+
define constant $serious-warnings-exit-code = 3;
1315

1416
define constant $whitespace = #[' ', '\t', '\n'];
1517
define constant $quote-characters = #['\'', '"'];

sources/environment/commands/module.dylan

+4-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ define module command-lines
8787
display-command-prompt,
8888
execute-command-line,
8989
execute-server-command,
90-
$error-exit-code,
91-
$success-exit-code;
90+
$success-exit-code,
91+
$unexpected-error-exit-code,
92+
$serious-warnings-exit-code,
93+
$usage-error-exit-code;
9294

9395
// Command line user interface
9496
export command-line-choose-file,

sources/environment/console/command-line.dylan

+3-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,9 @@ define method do-execute-command
160160
next-handler()
161161
else
162162
display-condition(context, condition);
163-
message(context, "Exiting with return code %d", $error-exit-code);
164-
return($error-exit-code)
163+
message(context, "Exiting with return code %d",
164+
$unexpected-error-exit-code);
165+
return($unexpected-error-exit-code)
165166
end
166167
end;
167168
local method run

sources/environment/console/start.dylan

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ define function main
2121
parse-command-line(server, arguments, class: class)
2222
exception (error :: <parse-error>)
2323
format(output-stream, "%s\n", error);
24-
exit-application($error-exit-code)
24+
exit-application($usage-error-exit-code)
2525
end;
2626
let status-code :: <integer> = execute-command(command);
2727
exit-application(status-code)

0 commit comments

Comments
 (0)