From d3696ed13b22e2297154e66c6ba7192ec7011905 Mon Sep 17 00:00:00 2001 From: kyodev Date: Wed, 13 Dec 2017 06:25:54 +0100 Subject: [PATCH] maj --- scripts/sdeb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/sdeb b/scripts/sdeb index 81a8109..78df7fa 100755 --- a/scripts/sdeb +++ b/scripts/sdeb @@ -1,7 +1,7 @@ #!/bin/bash -version=1.2.0 -date=7/12/2017 +version=1.3.0 +date=13/12/2017 f__color(){ # 08/10/2017 YELLOW=$(tput setaf 3) # question @@ -17,21 +17,21 @@ f__color(){ # 08/10/2017 } # $1=oui|non&[-tx] réponse par défaut & -tx=timeout, $2=message question, return 0 pour oui, 1 pour non -f__dialog_oui_non(){ # 5/12/2017 - local reply param +f__dialog_oui_non(){ # 12/12/2017 + local param [[ "$1" =~ -t[0-9]{1,2} ]] && param="$(sed -En 's/.*(-t[0-9]{1,2}).*/\1/p' <<< $1)" echo -en "$BLUE$2$STD" [[ "$1" =~ oui ]] && echo -n " [O/n] " || echo -n " [o/N] " if [ "$param" ]; then - read -t2 reply + read -t2 -r else - read reply + read -r fi - if [ -z "$reply" ]; then - [[ "$1" =~ oui ]] && reply="oui" || reply="non" + if [ -z "$REPLY" ]; then + [[ "$1" =~ oui ]] && REPLY="oui" || REPLY="non" fi echo - if [[ ${reply,,} =~ ^ou?i?$ ]]; then return 0; else return 1; fi + if [[ ${REPLY,,} =~ ^ou?i?$ ]]; then return 0; else return 1; fi } # $1=cmd si $2: nb de tentatives pour s'identifier, sinon 2 tentatives par défaut, suppose bash existant