*: Move die() into .local/bin/helpers.sh
The function `die` was redundantly implemented in various files. Move the function into .local/bin/helpers.sh and source that where previously implemented. Also prepend the program's name to the message and always terminate the message with a newline. The newline was previously needed for a small but unnecessary hack that prevented the need of the `[ -z "$1" ]` test.
This commit is contained in:
@@ -6,10 +6,8 @@
|
||||
#
|
||||
# To enable this hook, save this file in ".git/hooks/pre-commit".
|
||||
|
||||
die() {
|
||||
printf "$1" >&2
|
||||
exit ${2:-1}
|
||||
}
|
||||
# Source die()
|
||||
. "$HOME"/.local/bin/helpers.sh
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1; then
|
||||
against=HEAD
|
||||
@@ -35,8 +33,7 @@ if [ "$allownonascii" != "true" ]; then
|
||||
| wc -c
|
||||
)
|
||||
if [ $num_nonascii != 0 ]; then
|
||||
printf "Rename files to only include ASCII characters.\n" >&2
|
||||
die "Or set hooks.allownonascii to true.\n"
|
||||
die "Rename files with ASCII characters only, or enable hooks.allownonascii"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user