maintain/style: update err reference
it's a variable now, called err, rather than a function called err. the variable defines the name of a function that handles errors. Signed-off-by: Leah Rowe <info@minifree.org>master
parent
58820a1a61
commit
1e1d083c44
|
@ -83,7 +83,7 @@ attention to how the functions are formatted, e.g. where `{` and `}` go:
|
||||||
```
|
```
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
. "include/err.sh"
|
. "include/lib.sh"
|
||||||
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ main()
|
||||||
foo()
|
foo()
|
||||||
{
|
{
|
||||||
printf "I'm a function that does stuff.\n"
|
printf "I'm a function that does stuff.\n"
|
||||||
bar || err "foo: an error occured"
|
bar || $err "foo: an error occured"
|
||||||
do_something_else
|
do_something_else
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ bar()
|
||||||
do_something_else()
|
do_something_else()
|
||||||
{
|
{
|
||||||
complicated_function bla bla bla || \
|
complicated_function bla bla bla || \
|
||||||
err "do_something_else: something happened that wasn't nice"
|
$err "do_something_else: something happened that wasn't nice"
|
||||||
}
|
}
|
||||||
|
|
||||||
complicated_function()
|
complicated_function()
|
||||||
|
@ -170,7 +170,7 @@ However, neither of these should be relied upon exclusively. When a script runs
|
||||||
must be handled.
|
must be handled.
|
||||||
|
|
||||||
The general rule is to call `err()`, which is provided in cbmk by
|
The general rule is to call `err()`, which is provided in cbmk by
|
||||||
the file `include/err.sh`. This is inspired by the way `err()` is called in
|
the file `include/lib.sh`. This is inspired by the way `err()` is called in
|
||||||
BSD programs (from `err.h`, a non-standard BSD libc extension).
|
BSD programs (from `err.h`, a non-standard BSD libc extension).
|
||||||
|
|
||||||
Where a script must perform certain cleanup before exiting, the script should
|
Where a script must perform certain cleanup before exiting, the script should
|
||||||
|
@ -178,11 +178,11 @@ implement its own `fail()` function that performs cleanup, and then
|
||||||
calls `err()`. The `err()` function takes a string as argument, which will be
|
calls `err()`. The `err()` function takes a string as argument, which will be
|
||||||
printed to the screen.
|
printed to the screen.
|
||||||
|
|
||||||
If `err` is being called from `main()`, just write the error message. However,
|
If `$err` is being called from `main()`, just write the error message. However,
|
||||||
if it's being called from another function, you should write the function name.
|
if it's being called from another function, you should write the function name.
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
err "function_name: this shit doesn't work. fix it."
|
$err "function_name: this shit doesn't work. fix it."
|
||||||
|
|
||||||
Do not directly exit
|
Do not directly exit
|
||||||
--------------------
|
--------------------
|
||||||
|
@ -277,7 +277,7 @@ follow-up line. For example:
|
||||||
function_name()
|
function_name()
|
||||||
{
|
{
|
||||||
really stupidly long command that may also return error state || \
|
really stupidly long command that may also return error state || \
|
||||||
err "function_name: you screwed up. try again."
|
$err "function_name: you fucked up. try again."
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue