2019-09-09 04:38:13 +02:00
|
|
|
set -e
|
2019-09-25 22:19:51 +02:00
|
|
|
set - pos1 \
|
2019-09-09 04:38:13 +02:00
|
|
|
--val1 for_val1 \
|
|
|
|
--val2=for_val2 \
|
|
|
|
pos2 \
|
|
|
|
--flag1 \
|
|
|
|
-v4 for_val4 \
|
|
|
|
--flag2 \
|
|
|
|
|
2019-09-25 22:19:51 +02:00
|
|
|
source "${DIR_LIB}/opt.sh"
|
|
|
|
|
2019-09-09 04:38:13 +02:00
|
|
|
# Run a standard option parsing loop.
|
2019-09-25 22:19:51 +02:00
|
|
|
echo "PROGRAM: $PROGRAM"
|
2019-09-09 04:38:13 +02:00
|
|
|
while shiftopt; do
|
|
|
|
case "$OPT" in
|
|
|
|
--val*) shiftval; printf "LONG_OPTION: \"%s\" with value \"%s\"\n" "${OPT}" "${OPT_VAL}" ;;
|
|
|
|
--*) printf "LONG_FLAG: \"%s\"\n" "${OPT}" ;;
|
|
|
|
-v*) shiftval; printf "SHORT_OPTION: \"%s\" with value \"%s\"\n" "${OPT}" "${OPT_VAL}" ;;
|
|
|
|
-*) printf "SHORT_FLAG: \"%s\"\n" "${OPT}" ;;
|
|
|
|
*) printf "ARGUMENT: \"%s\"\n" "${OPT}" ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|