If $foo exists and is not null, return $foo. If it doesn't exist or is null, return bar. export foo... If $foo exists and is not null, return $foo. If it doesn't exist or is null, set $foo to bar and ret... } If $foo exists and is not null, return bar. If it doesn't exist, or is null, return a null. export... message"} If $foo exists and is not null, return its value. If it doesn't exist or is null, print the
[ ... ]
# If a string has not been initialized, it has no defined value.
# This state is called "nul... ng result.
# Shows $string1 as not null, although it was not initialized.
echo
# Let's try it again.
if [ -n "$string1" ] # This time, $string1 is quo... one detects whether the string is null.
# However it is good practice to quote it (if [ "$string1" ]).