un outil de sondage - retour accueil
git clone git://bebou.netlib.re/kun
Log | Files | Refs | README |
commit 09aa10e913de3e05457372efb73086f4af9a6054 parent 7281a9e9595a3620f4be72a602e3c65a8d34e669 Auteurice: Arthur Pons <arthur.pons@unistra.fr> Date: Wed, 20 Nov 2024 10:04:26 +0100 Correction bug quand on lançait sans argument Le case tentait quand même de lancer une commande, le vide balançait l'erreur "commande n'existe pas". On vérifie maintenant si le fichier de script contient des trucs avec de l'exec, sinon on passe au TUI. Diffstat:
M | kun.sh | | | 39 | +++++++++++++++++++++------------------ |
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/kun.sh b/kun.sh @@ -25,26 +25,29 @@ elif [ ! -t 0 ];then cat > $kunscript fi + # Probablement safe mais fastidieux -while read cmd;do - set -- $cmd - case "$1" in - (create) create "$2" || exit 1;; - (addanswer) addanswer "$2" "$3" "$4" || exit 1;; - (modifyanswer) modifyanswer "$2" "$3" "$4" || exit 1;; - (deletequestion) deletequestion "$2" || exit 1;; - (deleteanswer) deleteanswer "$2" "$3" || exit 1;; - (results) results "$2" || exit 1;; - (getpeople) getpeople "$2" || exit 1;; - (getanswer) getanswer "$2" "$3" || exit 1;; - (getlog) getlog "$2" || exit 1;; - (-h) _help;exit 0;; - (*) _die "Commande n'existe pas";exit 1;; - esac -done < $kunscript -# Si on lit pas depuis un term on termine ici -[ -s "$kunscript" ] && exit 0 +# Si kunscript n'est pas vide on l'exec +if [ -s "$kunscript" ];then + while read cmd;do + set -- $cmd + case "$1" in + (create) create "$2" || exit 1;; + (addanswer) addanswer "$2" "$3" "$4" || exit 1;; + (modifyanswer) modifyanswer "$2" "$3" "$4" || exit 1;; + (deletequestion) deletequestion "$2" || exit 1;; + (deleteanswer) deleteanswer "$2" "$3" || exit 1;; + (results) results "$2" || exit 1;; + (getpeople) getpeople "$2" || exit 1;; + (getanswer) getanswer "$2" "$3" || exit 1;; + (getlog) getlog "$2" || exit 1;; + (-h) _help;exit 0;; + (*) _die "Commande $1 n'existe pas";exit 1;; + esac + done < $kunscript + exit 0 +fi # Sinon on créé le fichier de log logfile=$(mktemp /tmp/kun.XXX.log)