mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-20 17:20:12 +01:00
Simplify options parsing and better handling for combined options
This commit is contained in:
@@ -430,32 +430,36 @@ EMPTY_JAIL=""
|
|||||||
THICK_JAIL=""
|
THICK_JAIL=""
|
||||||
VNET_JAIL=""
|
VNET_JAIL=""
|
||||||
|
|
||||||
## handle combined options then shift
|
# Handle and parse options
|
||||||
if [ "${1}" = "-T" -o "${1}" = "--thick" -o "${1}" = "thick" ] && \
|
while [ $# -gt 0 ]; do
|
||||||
[ "${2}" = "-V" -o "${2}" = "--vnet" -o "${2}" = "vnet" ]; then
|
|
||||||
THICK_JAIL="1"
|
|
||||||
VNET_JAIL="1"
|
|
||||||
shift 2
|
|
||||||
else
|
|
||||||
## handle single options
|
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
-E|--empty|empty)
|
-E|--empty|empty)
|
||||||
shift
|
|
||||||
EMPTY_JAIL="1"
|
EMPTY_JAIL="1"
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
-T|--thick|thick)
|
-T|--thick|thick)
|
||||||
shift
|
|
||||||
THICK_JAIL="1"
|
THICK_JAIL="1"
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
-V|--vnet|vnet)
|
-V|--vnet|vnet)
|
||||||
shift
|
|
||||||
VNET_JAIL="1"
|
VNET_JAIL="1"
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
-*)
|
-*|--*)
|
||||||
error_notify "Unknown Option."
|
error_notify "Unknown Option."
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
## validate for combined options
|
||||||
|
if [ -n "${EMPTY_JAIL}" ]; then
|
||||||
|
if [ -n "${THICK_JAIL}" ] || [ -n "${VNET_JAIL}" ]; then
|
||||||
|
error_exit "Error: Empty jail option can't be used with other options."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NAME="$1"
|
NAME="$1"
|
||||||
|
|||||||
Reference in New Issue
Block a user