Script will now stop if there are errors in the options

This commit is contained in:
Antonin Décimo
2013-11-08 18:04:37 +01:00
parent 43f9770dd2
commit c828412056

View File

@@ -73,8 +73,9 @@ function getoptex()
if [ -z "$OPTARG" ];
then # error: must have an agrument
let OPTERR && echo "$0: error: $OPTOPT must have an argument" >&2
OPTARG="$OPTOPT";
OPTOPT="?"
exit
# OPTARG="$OPTOPT";
# OPTOPT="?"
return 1;
fi
OPTIND=$[OPTIND+1] # skip option's argument
@@ -84,8 +85,9 @@ function getoptex()
if [ "$opttype" = ";" ];
then # error: must not have arguments
let OPTERR && echo "$0: error: $OPTOPT must not have arguments" >&2
OPTARG="$OPTOPT"
OPTOPT="?"
exit
# OPTARG="$OPTOPT"
# OPTOPT="?"
return 1
fi
OPTARG=${o#"--$OPTOPT="}
@@ -101,8 +103,9 @@ function getoptex()
if [ -z "$OPTARG" ]
then
echo "$0: error: -$OPTOPT must have an argument" >&2
OPTARG="$OPTOPT"
OPTOPT="?"
exit
# OPTARG="$OPTOPT"
# OPTOPT="?"
return 1
fi
OPTIND=$[OPTIND+1] # skip option's argument
@@ -124,6 +127,7 @@ function getoptex()
fi
done
echo "$0: error: invalid option: $o"
exit
fi; fi
OPTOPT="?"
unset OPTARG