I'm writing a Korn Shell.
I want to assign default values to environment variables only if they
not already set. A null string value is valid.
Before invoking script.
Now inside my script I want the following logic, (pseudo code)
if ( $str1 doesn't exist )
export str1="str1 set to default"
if ( $str2 doesn't exist )
export str3="str2 set to default"
if ( $str3 doesn't exist )
export str3="str3 set to default"
print "str1= $str1"
print "str2= $str2"
print "str3= $str3"
I should see the following on the screen:
str3= str3 set to default
My problem is that I don't know how to detect the difference between an
unset variable and a variable whose value is null.
( i.e. str2 and str3 ).
Does anybody know how?
Thanks in advance.