Merge branch 'set_var-v2' of ssh://github.com/TinCanTech/easy-rsa into 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:04 +00:00
commit 9d21db8629
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()