From 7106ed16584f6e4af64b952442cf970d416aedb3 Mon Sep 17 00:00:00 2001 From: Hippolyte Chauvin Date: Mon, 3 Jul 2023 20:01:25 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20:=20v=C3=A9rification=20si=20l'utilisat?= =?UTF-8?q?ion=20de=20la=20commande=20est=20valide=20dans=20les=20fonction?= =?UTF-8?q?s=20qui=20n=C3=A9cessitent=20un=20argument?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/mcserv | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/bin/mcserv b/bin/mcserv index 2871fe3..e64fb8c 100755 --- a/bin/mcserv +++ b/bin/mcserv @@ -25,21 +25,33 @@ error_usage() { } public_start() { - mcscreen -d -m -S "$1" \ - "/srv/minecraft/bin/${1}" + if [ -n "$1" ]; then + mcscreen -d -m -S "$1" \ + "/srv/minecraft/bin/${1}" + else + error_usage + fi } public_status() { - printf '\033[1m%s\033[0m : ' "$1" - if mcscreen -ls "$1" > /dev/null 2>&1; then - echo "en cours d'exécution" + if [ -n "$1" ]; then + printf '\033[1m%s\033[0m : ' "$1" + if mcscreen -ls "$1" > /dev/null 2>&1; then + echo "en cours d'exécution" + else + echo "non en cours d'exécution" + fi else - echo "non en cours d'exécution" + error_usage fi } public_stop() { - mcscreen -S "$1" -X stuff '^E^Ustop^M' + if [ -n "$1" ]; then + mcscreen -S "$1" -X stuff '^E^Ustop^M' + else + error_usage + fi } public_watch() {