From a9acae3ca392c6caaabdff7f4cd17aba0384b715 Mon Sep 17 00:00:00 2001 From: primardj Date: Tue, 23 Jan 2024 21:19:36 +0000 Subject: [PATCH] change a if elif elif elif else by a case --- vm-start.sh | 71 +++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/vm-start.sh b/vm-start.sh index b429e21..f205bc8 100755 --- a/vm-start.sh +++ b/vm-start.sh @@ -240,39 +240,40 @@ then fi -if [ "$2" == "start" ] -then - echo "starting VM $1" - START -elif [ "$2" == "start-backup" ] -then - echo "starting VM rescue" - START_BACKUP -elif [ "$2" == "backup" ] -then - echo "backup VM" - BACKUP -elif [ "$2" == "restore" ] -then - echo "restore VM" - RESTORE -elif [ "$2" == "create" ] -then - echo "creating VM" - if [ $# -ge 3 ] - then - echo "using image disk $3" # Error here, please don't think that there will be only three devices, should be improve like with an install-device parametter. - CREATE "$3" # TODO - else - echo "$#" - echo "Error, no image defined." >&2 - fi -elif [ "$2" == "suppr" ] -then - echo "suppressing all data of the vm $1" - SUPPRESS "$1" -else - echo "commande $2 inconnue" >&2 - HELP -fi +case "$2" in + "start") + echo "starting VM $1" + START + ;; + "start-backup") + echo "starting VM rescue" + START_BACKUP + ;; + "backup") + echo "backup VM" + BACKUP + ;; + "restore") + echo "restore backup" + RESTORE + ;; + "create") + echo "creating VM" + if [ $# -ge 3 ] + then + echo "using image disk $3" + CREATE "$3" + else + echo "$#" + echo "Error, no image defined." >&2 + fi + ;; + "suppr") + echo "suppressing all data of the vm $1" + SUPPRESS "$1" + ;; + "*") + echo "commande $2 inconnue" >&2 + HELP +esac