Merge branch 'TinCanTech-set_var-v2'

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
This commit is contained in:
Richard T Bonhomme 2023-02-11 21:54:57 +00:00
commit 41f23444c6
No known key found for this signature in database
GPG Key ID: 2D767DB92FB6C246

View File

@ -4740,10 +4740,10 @@ Using SSL: $EASYRSA_OPENSSL $ssl_version
# the variable when it is already defined (even if currently null)
# Sets $1 as the value contained in $2 and exports (may be blank)
set_var() {
var=$1
shift
value="$*"
eval "export $var=\"\${$var-$value}\""
[ "$1" ] || die "set_var - missing input"
[ "$1" = "${1% *}" ] || die "set_var - input error"
[ "$#" -lt 3 ] || die "set_var - excess input"
eval "export \"$1\"=\"\${$1-$2}\""
} #=> set_var()