I have a script with several options and during testing I found that the \? option does not handle options without dashes as I would expect. Then I run the script with any option that does not include a dash, it runs the script when I would expect \? to catch it and error.
I've tried this with OPTERR=0 and OPTERR=1 and don't get any errors. Do I need to write a function to catch options without dashes? Seems that would be something getopts should catch.
#!/usr/bin/bash
OPTERR=1
while getopts :P::E::I::L::b:ftdorvxhn optn
do
case ${optn} in
P) echo "PORTX=${OPTARG}" ;;
E) echo "EXCLUDE_FILE=${OPTARG}" ;;
I) echo "IP_ARRAY=${OPTARG}" ;;
L) echo "IP_LIST=${OPTARG}" ;;
b) echo "Running function: ${OPTARG}" ;;
f) echo "pre_flight chk_preflight" ;;
t) echo "flar_size_total" ;;
d) echo "dupe_flar_chk" ;;
o) echo "old_flar_chk" ;;
r) echo "rotate_logs" ;;
v) echo "Not yet implemented." ;;
x) echo "get expl file" ;;
h) echo "USAGE 0; exit 0" ;;
n) echo "USAGE 1;exit 0" ;;
\?) echo "help or unknown" ;;
:) echo "ERROR: Option requires an arguement." ;;
esac
done
Thanks,
HexKnot