qemush : remplacement du if précédent par un case POSIX
This commit is contained in:
parent
7c4e645fa0
commit
50fba776c8
1 changed files with 13 additions and 19 deletions
32
bin/qemush
32
bin/qemush
|
@ -193,23 +193,17 @@ public_spice() {
|
||||||
socat TCP-LISTEN:"${port},reuseaddr,fork" UNIX-CLIENT:"$(pathof spice)"
|
socat TCP-LISTEN:"${port},reuseaddr,fork" UNIX-CLIENT:"$(pathof spice)"
|
||||||
}
|
}
|
||||||
|
|
||||||
function_exists() {
|
case "$1" in
|
||||||
declare -F \
|
"")
|
||||||
| cut -d \ -f 3- \
|
public_running
|
||||||
| grep '^public_' \
|
;;
|
||||||
| sed 's/^public_//' \
|
running|ls|add|edit|start|attach|rm|diskls|diskadd|diskrm|shell|do|spice|help)
|
||||||
| grep -q "^${1}\$"
|
function=$1
|
||||||
}
|
shift
|
||||||
|
|
||||||
# Defauts to `active` if no function is supplied; else checks for a public
|
"public_${function}" "$@"
|
||||||
# function named after the argument; else fails
|
;;
|
||||||
if [ -z "$1" ]; then
|
*)
|
||||||
public_running
|
error_usage
|
||||||
elif function_exists "$1"; then
|
;;
|
||||||
function=$1
|
esac
|
||||||
shift
|
|
||||||
|
|
||||||
"public_${function}" "$@"
|
|
||||||
else
|
|
||||||
error_usage
|
|
||||||
fi
|
|
||||||
|
|
Loading…
Reference in a new issue