From 0044e1dc7c01966ac5a2e0a89663c025a2a8648c Mon Sep 17 00:00:00 2001 From: Arndt Kaiser Date: Mon, 11 May 2020 09:40:38 +0200 Subject: [PATCH] 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. --- easyrsa3/easyrsa | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/easyrsa3/easyrsa b/easyrsa3/easyrsa index 2e5d13b..6a50152 100755 --- a/easyrsa3/easyrsa +++ b/easyrsa3/easyrsa @@ -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)