Catch no arguments being passed

This commit is contained in:
Martin Wimpress 2020-08-10 13:07:45 +01:00
parent bae1dedf3a
commit 4aa38ad8f9
No known key found for this signature in database
GPG key ID: 61DF940515E06DA3

View file

@ -554,48 +554,54 @@ QEMU="/snap/bin/qemu-virgil"
QEMU_IMG="/snap/bin/qemu-virgil.qemu-img" QEMU_IMG="/snap/bin/qemu-virgil.qemu-img"
VIRGIL_PATH="/snap/qemu-virgil/current" VIRGIL_PATH="/snap/qemu-virgil/current"
while [ $# -gt 0 ]; do # Take command line arguments
case "${1}" in if [ $# -lt 1 ]; then
-delete|--delete) usage
DELETE=1 exit 0
shift;; else
-snapshot|--snapshot) while [ $# -gt 0 ]; do
SNAPSHOT_ACTION="${2}" case "${1}" in
if [ -z "${SNAPSHOT_ACTION}" ]; then -delete|--delete)
echo "ERROR! No snapshot action provided." DELETE=1
exit 1 shift;;
fi -snapshot|--snapshot)
shift SNAPSHOT_ACTION="${2}"
SNAPSHOT_TAG="${2}" if [ -z "${SNAPSHOT_ACTION}" ]; then
if [ -z "${SNAPSHOT_TAG}" ] && [ "${SNAPSHOT_ACTION}" != "info" ]; then echo "ERROR! No snapshot action provided."
echo "ERROR! No snapshot tag provided." exit 1
exit 1 fi
fi shift
shift SNAPSHOT_TAG="${2}"
shift;; if [ -z "${SNAPSHOT_TAG}" ] && [ "${SNAPSHOT_ACTION}" != "info" ]; then
-status-quo|--status-quo) echo "ERROR! No snapshot tag provided."
STATUS_QUO="-snapshot" exit 1
shift;; fi
-fullscreen|--fullscreen) shift
FULLSCREEN="--full-screen" shift;;
shift;; -status-quo|--status-quo)
-vm|--vm) STATUS_QUO="-snapshot"
VM="${2}" shift;;
shift -fullscreen|--fullscreen)
shift;; FULLSCREEN="--full-screen"
-shortcut|--shortcut) shift;;
SHORTCUT=1 -vm|--vm)
shift;; VM="${2}"
-system-qemu|--system-qemu) shift
SYSTEM_QEMU=1 shift;;
shift;; -shortcut|--shortcut)
-h|--h|-help|--help) SHORTCUT=1
usage;; shift;;
*) -system-qemu|--system-qemu)
echo "ERROR! \"${1}\" is not a supported parameter." SYSTEM_QEMU=1
usage;; shift;;
esac -h|--h|-help|--help)
done usage;;
*)
echo "ERROR! \"${1}\" is not a supported parameter."
usage;;
esac
done
fi
if [ -n "$SYSTEM_QEMU" ]; then if [ -n "$SYSTEM_QEMU" ]; then
QEMU=$(which qemu-system-x86_64) QEMU=$(which qemu-system-x86_64)