This commit is contained in:
kyodev 2017-12-13 06:25:54 +01:00
parent 0f5569f62e
commit d3696ed13b
1 changed files with 9 additions and 9 deletions

View File

@ -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