From 50fba776c8c4ca62719997686589616ae63df83f Mon Sep 17 00:00:00 2001 From: Ahurac Date: Mon, 25 Mar 2024 11:43:20 +0100 Subject: [PATCH] =?UTF-8?q?qemush=20:=20remplacement=20du=20if=20pr=C3=A9c?= =?UTF-8?q?=C3=A9dent=20par=20un=20case=20POSIX?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/qemush | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/bin/qemush b/bin/qemush index 637f631..41c00cd 100755 --- a/bin/qemush +++ b/bin/qemush @@ -193,23 +193,17 @@ public_spice() { socat TCP-LISTEN:"${port},reuseaddr,fork" UNIX-CLIENT:"$(pathof spice)" } -function_exists() { - declare -F \ - | cut -d \ -f 3- \ - | grep '^public_' \ - | sed 's/^public_//' \ - | grep -q "^${1}\$" -} +case "$1" in + "") + public_running + ;; + running|ls|add|edit|start|attach|rm|diskls|diskadd|diskrm|shell|do|spice|help) + function=$1 + shift -# Defauts to `active` if no function is supplied; else checks for a public -# function named after the argument; else fails -if [ -z "$1" ]; then - public_running -elif function_exists "$1"; then - function=$1 - shift - - "public_${function}" "$@" -else - error_usage -fi + "public_${function}" "$@" + ;; + *) + error_usage + ;; +esac