Closed ktm5j closed 5 years ago
Variables in Elvish are lexically scoped, so it is not possible to refer to a nonexistent variable. This is intentional: https://elv.sh/ref/language.html#scoping-rule
What is your use case for this?
I'm trying to duplicate the functionality of environment modules (http://modules.sourceforge.net/).. but I'm now realizing that I can use has-env
from the builtin module for what I need. Thanks for the info!
Can someone tell me the correct way to test if a variable has been set? Like how in bash you do
if [ -n "$VAR" ]
Everything I try leads to a runtime failure saying
Compilation error: variable $VAR not found
, even if I wrap it in atry
block.Thanks!