The getopts command doesn't seem to work in a function. Maybe I did something wrong. The code below is what I have now. it is working if I put the whole while loop outside function. I am wondering if there is a way to make getopts work with functions ? I am new to the shell script. Any help would be appreciated :)
getOptions()
{
while getopts :al:f:vd opt; do
case "$opt" in
l) logFile = $OPTARG ;;
f) fileTable = $OPTARG ;;
v) verbose = 1 ;;
d) set -x ;;
a) echo "a";;
\?) echo "Invalid option: -$opt";;
esac
done
shift $(($OPTIND - 1))
}