This is my script. I adapted it from this tutorial so it can't be an error in the script itself. (The original script had the same problem.)
#!/bin/bash
while getopts "a:" opt; do
case $opt in
a)
echo "-a was triggered, Parameter: $OPTARG"
;;
esac
done
Here's my output:
bash-3.2$ source getopt.sh
bash-3.2$ source getopt.sh -a /dev/null
-a was triggered, Parameter: /dev/null
bash-3.2$ source getopt.sh -a /dev/null
bash-3.2$
I've combed the Internet and can't find any explanation for this behavior.