First off, I apologize for my lack of knowledge. I realize my problem will probably seem pretty basic to everyone, but I've been at this for several hours now and I've gotten nowhere. I would contact my professor, but it is too late for that.
Anyway, I'm trying to write a function called CheckOptions which is passed a string of characters indicating which options may be used. In it, I use getopts to verify that the options are valid. Now from my understanding, in getopts when an unknown option is presented, OPTARG is set to that unknown option, however this does not seem to be the case for me. Am I wrong in assuming that this is done automatically?
CheckOptions()
{
validOpts=$1
shift
while getopts $validOpts optLetter ; do
echo $optLetter $OPTIND $OPTARG
done
}
CheckOptions "abc" -a -b -d
if [[ $? -eq 0 ]] ; then
echo OPTIND = $OPTIND
else
echo OPTARG = $OPTARG
fi