I'm trying to write a simple function that checks whether a variables is declared and non empty or not.
my_var="dummy_val"
function validate_var(){
${1:?"Variable is not set"}
}
validate_var my_var
validate_var my_var2
I get the following error:
script: line n: my_var: command not found
Is there a simple way I could reference the variable from the function argument?