In Bash you can check if an environment variable is set with test -v FOO
. It doesn't work in Dash on Debian 11 though because its test
doesn't support -v
:
# test -v FOO
dash: 2: test: -v: unexpected operator
Is there a portable way that works in Bash and Dash (and ideally more shells, but those are the main ones I am concerned with)?