Please consider the following Bash function.
#!/bin/bash
function assert_var(){
echo "check if variable with name $1 exists"
if [ -z $1 ];then
echo "EXISTS!"
else
echo "NOT EXISTS!"
fi
}
export FOO="123"
assert_var "FOO"
assert_var "BAR"
The expectation is that variable FOO should be detected and absence of BAR as well. For that, I need somehow to pass and use the variable name as argument to the function.
How to do that properly?