This works!
Problem is, when I wana put it, in a function, which takes one arg, that is a name of a variable, to be checked.
This part of code, inside a function, always fails:
As well as:
Anyone?
Code:
# var exists
if [ "${var-NON_EXISTING}" != 'NON_EXISTING' ]; then
# and is empty
[ ! "$var" ] && echo "Var \$var exists and is empty"
fi
Problem is, when I wana put it, in a function, which takes one arg, that is a name of a variable, to be checked.
This part of code, inside a function, always fails:
Code:
... "${$@-NON_EXISTING}" ...
Code:
... "${"$@"-NON_EXISTING}" ...
Code:
... "${`echo $@`-NON_EXISTING}" ...
Code:
... "${"`echo $@`"-NON_EXISTING}" ...