-#!/bin/bash
-#
# SPDX-FileCopyrightText: 2021-2022 EfficiOS, Inc.
# SPDX-License-Identifier: GPL-2.0-only
+# shellcheck shell=bash
+
# 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 $(eval echo "\$$varname") ]]; then
+ if [[ -z $(eval echo "\${$varname:-}") ]]; then
eval "$varname='$val'"
fi