mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-24 11:16:51 +00:00
config/functions: add die() function
die is meant to be a more flexible exit, printing a message to go with the exit call. It works like: die -- same as "exit 1" die "It just broke." -- echo statement, exit value 1 die "Tried to do the thing." "2" -- echo statement, exit value 2 Exit codes other than 1 require a message to go with it. it would replace existing code that looks like: echo "ERROR: Everything went wrong. Sorry!" exit 1 or be more helpful in picking up the pieces when something unexpected happens then: do_something || exit 1 Signed-off-by: Ian Leonard <antonlacon@gmail.com>
This commit is contained in:
parent
f0c1537041
commit
aa00529d3a
@ -1,4 +1,12 @@
|
||||
### FUNCTION HELPERS ###
|
||||
# die (message, code) abort with optional message and code
|
||||
die() {
|
||||
if [ -n "$1" ]; then
|
||||
echo -e "$1" >&2
|
||||
fi
|
||||
exit "${2:-1}"
|
||||
}
|
||||
|
||||
# return 0 if $2 in space-separated list $1, otherwise return 1
|
||||
listcontains() {
|
||||
if [ -n "$1" -a -n "$2" ]; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user