From 3c6e04f8451b48ba60d977bc9235b18931cbe9c2 Mon Sep 17 00:00:00 2001 From: ycharbi Date: Sun, 11 Feb 2024 11:56:00 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d'une=20v=C3=A9rification=20sur=20la=20?= =?UTF-8?q?pr=C3=A9sence=20d'un=20tiret=20au=20premier=20caract=C3=A8re=20?= =?UTF-8?q?du=20param=C3=A8tre=20pass=C3=A9.=20Cela=20permet=20d'=C3=A9vit?= =?UTF-8?q?er=20de=20consid=C3=A9rer=20la=20prochaine=20option=20comme=20p?= =?UTF-8?q?aram=C3=A8tre=20de=20l'option=20courante?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qemu-adm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/qemu-adm b/qemu-adm index 3e4a64a..e21921d 100755 --- a/qemu-adm +++ b/qemu-adm @@ -151,7 +151,7 @@ presenceParametre() local l_nombre_arguments="${1}" local l_nom_option="${2}" local l_nombre_parametres=${l_nombre_arguments}-1 # On soustrait l'option du nombre d'arguments resultant le nombre de parametres - if [[ "${l_nombre_parametres}" -eq 0 ]]; then + if [[ "${l_nombre_parametres}" -eq 0 || "${3:0:1}" == "-" ]]; then die "L'option ${l_nom_option} n'a pas de paramètre." 5 fi } @@ -168,7 +168,7 @@ creeMV() echo "cpu" # Debogage parametre="${2}" echo "cpu parametre=${parametre}" # Debogage - presenceParametre "$#" "$1" + presenceParametre "$#" "${1}" "${parametre}" shift if [[ ${temoin_c} -ne 1 ]]; then # :: @@ -201,7 +201,7 @@ creeMV() echo "memoire" # Debogage parametre="${2}" echo "memoire parametre=${parametre}" # Debogage - presenceParametre "$#" "$1" + presenceParametre "$#" "${1}" "${parametre}" shift if [[ ${temoin_m} -ne 1 ]]; then commandes_a_executer+=( "nouvMV memoire ${1}") @@ -214,7 +214,7 @@ creeMV() echo "bios" # Debogage parametre="${2}" echo "bios parametre=${parametre}" # Debogage - presenceParametre "$#" "$1" + presenceParametre "$#" "${1}" "${parametre}" shift if [[ ${temoin_b} -ne 1 ]]; then case ${1} in @@ -233,7 +233,7 @@ creeMV() "-d") # Disque echo "disque" # Debogage parametre="${2}" - presenceParametre "$#" "$1" + presenceParametre "$#" "${1}" "${parametre}" echo "disque parametre=${parametre}" # Debogage shift @@ -241,6 +241,7 @@ creeMV() disque_nom=$( echo ${1} | awk -F: '{print $1}' ) echo "disque_nom=${disque_nom}" # Debogage + if [[ -z "${disque_nom}" ]]; then die "Le disque n'est pas renseigné.\nSyntaxe attendue : |(|):(raw|qcow2):)." 5 fi @@ -248,7 +249,6 @@ creeMV() disque_nom="${base_chemin_mv}/${disque_nom}" fi - disque_format=$( echo ${1} | awk -F: '{print $2}' ) echo "disque_format=${disque_format}" # Debogage if [[ -z "${disque_format}" && "$(dirname ${1})" == "." ]]; then @@ -266,7 +266,7 @@ creeMV() "-i") # Iso echo "iso" # Debogage parametre="${2}" - presenceParametre "$#" "$1" + presenceParametre "$#" "${1}" "${parametre}" echo "iso parametre=${parametre}" # Debogage shift commandes_a_executer+=( "nouvMV iso ${1}") @@ -274,7 +274,7 @@ creeMV() '-r') # Reseau echo "reseau" # Debogage parametre="${2}" - presenceParametre "$#" "$1" + presenceParametre "$#" "${1}" "${parametre}" echo "reseau parametre=${parametre}" # Debogage shift @@ -400,7 +400,7 @@ creeMV() echo "sous-volume" # Debogage parametre="${2}" echo "sous-volume parametre=${parametre}" # Debogage - presenceParametre "$#" "$1" + presenceParametre "$#" "${1}" "${parametre}" shift if [[ ${temoin_S} -ne 1 ]]; then case ${1} in @@ -436,7 +436,7 @@ creeMV() ;; "-a") # Affichage echo "Affichage" # Debogage - presenceParametre "$#" "$1" + presenceParametre "$#" "${1}" "${parametre}" shift # (gtk|(spice:(|):(|unix)[:])) @@ -493,7 +493,7 @@ creeMV() ;; '--') # Autre parametres (champ libre) echo "parametres" # Debogage - presenceParametre "$#" "$1" + presenceParametre "$#" "${1}" "${parametre}" shift parametres="$@" echo "parametres=${parametres}" # Debogage