#!/bin/bash
# Demo of Operators on Variables

# The value of FOO
FOO=hello
echo ${FOO}

# The length (in characters of the value of the varaible FOO)
echo ${#FOO}

# The value of the variable FOO if it is non-empty
# If the value of FOO is empty,
# it aborts the shell script and prints the msg on standard error
echo ${FOO:?"FOO Doesn't Exist"}
# Erase FOO
`FOO=
# Aborts the program if FOO is empty
echo ${FOO:?"FOO Doesn't Exist"}

# The value of the variable FOO if it is non-empty.
# If the value of FOO is empty, it is replaced by alternate
# The value of FOO is not modified, however
FOO=
echo ${FOO:-"FOO was empty"}
echo $FOO

# The value of the variable FOO if it is non-empty
# If the value of FOO is empty, it is replaced by alternate
# The value of FOO is also set to alternate
FOO=
echo ${FOO:="FOO was empty"}
echo $FOO