I'm trying to write a script in a way that makes it simple to add future command line args. I'm using getopts and that works well. However, I'm running into issues with the case statement.
args=`getopt lLo:t: $*`
if [ $? -ne 0 ]
then
echo "Usage: Default error message"
fi
while [ "$#" -eq 3 ] || [ "$#" -eq 5 ]
do
if [ "$1" != "-o" ] && [ "$1" != "-t" ]
then
echo "\nInvalid argument sequence."
exit 1
fi
case "$1" in
(-o)
shift
VAR1="$1"
shift
;;
(-t)
shift
VAR2="$1"
shift
;;
(*)
LAST_VAR="$1"
;;
(--) shift; break;;
esac
done
If I then echo $LAST_VAR it is null. Any ideas? Is there a better way to do this?