X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=tests%2Futils%2Fenv.sh.in;fp=tests%2Futils%2Fenv.sh.in;h=4cd75ce14f69de861a576f02599ee63e724808b5;hp=12069fef8cfafdbecf01304d7b80e885c68803d6;hb=4847ff77fd02c67f994b09f53babcbe5086b07dd;hpb=66a1e0899ac7588a560e9ffe306e06345989d29c diff --git a/tests/utils/env.sh.in b/tests/utils/env.sh.in index 12069fef..4cd75ce1 100644 --- a/tests/utils/env.sh.in +++ b/tests/utils/env.sh.in @@ -3,12 +3,13 @@ # SPDX-FileCopyrightText: 2021-2022 EfficiOS, Inc. # SPDX-License-Identifier: GPL-2.0-only -# Sets the variable named `$1` to `$2` if it's not set, and exports it. +# Sets the variable named `$1` to `$2` if it's not set (or empty), and +# exports it. _set_var_def() { local -r varname=$1 local -r val=$2 - if [[ -z ${!varname:-} ]]; then + if [[ -z $(eval echo "\$$varname") ]]; then eval "$varname='$val'" fi