tests/utils/utils.sh: remove redundancy when setting def. var. values
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 10 Nov 2023 05:41:41 +0000 (00:41 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 7 Feb 2024 21:25:56 +0000 (16:25 -0500)
commit82057d0ccb3be005f1c1d292a3ae663dec6499ad
treef3193fff8583285f5cb7e80da8b12d25a48b9456
parent7121d33d13acda261957ebf4c9912907f89f64f9
tests/utils/utils.sh: remove redundancy when setting def. var. values

This patch removes more redundancy in `utils.sh` by using a function
which sets a variable by name if it's empty and exports it.

This makes the file less error-prone: the variable name is written just
once, making it safer to add more.

The

    export "${varname?}"

form is to make ShellCheck happy, even if a simple `export $varname`
would perfectly work in this context.

The function is unset when it's not needed anymore to avoid polluting
the scope of whatever sources `utils.sh`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I6e25aa557f4d09f8129121b76b8b3a860ba3ed29
tests/utils/utils.sh
This page took 0.02381 seconds and 4 git commands to generate.