Functions notice() and warn() return with success now

The functions notice() and warn() allways exited with an return-code !=
0 if called in batch-mode, which can cause unexpected behavior in the
calling code. Now it is ensured that they return with succes.

Additinally, the Script will now terminate if the printf command in the
function print() fails. This ensures that errors during
output-generation will not be ignored.
This commit is contained in:
Arndt Kaiser 2020-05-11 09:40:38 +02:00
parent c505a14be5
commit 0044e1dc7c

View File

@ -262,7 +262,7 @@ Deprecated features:
# Wrapper around printf - clobber print since it's not POSIX anyway
# shellcheck disable=SC1117
print() { printf "%s\n" "$*"; }
print() { printf "%s\n" "$*" || exit 1; }
# Exit fatally with a message to stderr
# present even with EASYRSA_BATCH as these are fatal problems
@ -279,6 +279,8 @@ warn() {
[ ! "$EASYRSA_BATCH" ] && \
print "
$1" 1>&2
return 0
} # => warn()
# informational notices to stdout
@ -286,6 +288,8 @@ notice() {
[ ! "$EASYRSA_BATCH" ] && \
print "
$1"
return 0
} # => notice()
# yes/no case-insensitive match (operates on stdin pipe)