From b45ddd642e9173f73bb87c3cf4c80f1327461542 Mon Sep 17 00:00:00 2001 From: Simeon Ehrig Date: Mon, 2 Sep 2024 13:15:42 +0200 Subject: [PATCH] CI: extend env2cmake() to exit if a variable is not defined --- script/run_generate.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/script/run_generate.sh b/script/run_generate.sh index e17fd8fb335..cff1ad53b70 100755 --- a/script/run_generate.sh +++ b/script/run_generate.sh @@ -21,15 +21,24 @@ echo_green "" # # @param $1 cmake/environment variable name # -# @result if $1 exists cmake variable definition else nothing is returned +# @result if $1 exists cmake variable definition else nothing is returned. If variable is not +# defined, the script will be exited. # # @code{.bash} # FOO=ON +# BAR="" # echo "$(env2cmake FOO)" # returns "-DFOO=ON" # echo "$(env2cmake BAR)" # returns nothing +# echo "$(env2cmake FOOBAR)" # exit 1 # @endcode function env2cmake() { + # check if variable is definded + if [ -z ${!1+x} ]; then + kill -SIGTERM $$ + fi + + # return only content of variable is not empty if [ ! -z "${!1}" ] ; then echo -n "-D$1=${!1}" fi