-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Book: Draft for exit code chapter #61
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed
src/in-depth/exit-code.md
Outdated
@@ -1 +1,55 @@ | |||
# Exit codes | |||
|
|||
A program doesn't always success. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
succeed
src/in-depth/exit-code.md
Outdated
|
||
A program doesn't always success. | ||
And when an error occurs, | ||
you should make sure to use the correct ways to emit the necessary information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a correct way
or
you should make sure to emit the necessary information correctly.
src/in-depth/exit-code.md
Outdated
You should try to emit the correct code | ||
for your program's state. | ||
For example, | ||
in the ideal case when your program succeeded, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when your program succeeds,
src/in-depth/exit-code.md
Outdated
in the ideal case when your program succeeded, | ||
it should exit with `0`. | ||
|
||
When an error ocurred, it gets a bit more complicated, though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/occured/occurs
src/in-depth/exit-code.md
Outdated
When an error ocurred, it gets a bit more complicated, though. | ||
In the wild, | ||
a lot of tools exit with `1` when a general failure ocurred. | ||
Currently, Rust set and exit code of `101` when the process panicked. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, Rust sets an exit code of ...
src/in-depth/exit-code.md
Outdated
In the wild, | ||
a lot of tools exit with `1` when a general failure ocurred. | ||
Currently, Rust set and exit code of `101` when the process panicked. | ||
Beyond that, many people have done many things in their programs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beyond that, many people have ...
src/in-depth/exit-code.md
Outdated
So, what to do? | ||
The BSD ecosystem has collected a common definition for their exit codes | ||
in a system-provided header file called [`sysexits.h`] | ||
The Rust library [`exitcode`] provides these same codes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provides the same codes which are ready ...
src/in-depth/exit-code.md
Outdated
in a system-provided header file called [`sysexits.h`] | ||
The Rust library [`exitcode`] provides these same codes | ||
ready to be used in your application. | ||
Please see it's API documentation for the possible values to use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/it's/its
Thanks so much, @Dylan-DPC! |
src/in-depth/exit-code.md
Outdated
on most systems, | ||
when a process exits, | ||
it also emits an exit code | ||
(an integer between 0 and 255). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On POSIX, an exit code is a u8, while on Win32 an exit code is a u32 (weirdly, std::process::exit
takes an i32, I'm not sure why). It's probably best not to mention the actual limits until you get to a "platform-specific behaviour" section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "an integer between 0 and 255 is compatible with most platforms"?
src/in-depth/exit-code.md
Outdated
|
||
So, what to do? | ||
The BSD ecosystem has collected a common definition for their exit codes | ||
in a system-provided header file called [`sysexits.h`] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it appropriate to assume the reader will understand "a system-provided header file"? A lot of people certainly will, but somebody who comes here right after finishing TRPL might not.
If this book is aimed at an audience that already knows what header files are, that's fine, I just thought I'd mention it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I wanted to point to the source of the exit code list but you're right that is probably more confusing than helpful.
Merging to get this on the site, but always re-reviewable in #58 :) |
Resolves #39