diff --git a/scripts/getIp b/scripts/getIp index a01e575..3e8eacc 100755 --- a/scripts/getIp +++ b/scripts/getIp @@ -1,7 +1,7 @@ #!/bin/bash -version=2.4.0 -date="12/01/2018" +version=2.5.0 +date="14/01/2018" projet="simpledeb" contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/" script="getIp" @@ -130,9 +130,10 @@ f__requis(){ # 4/12/2017 fi } - # $1=cmd si $2: nb de tentatives pour s'identifier, sinon 2 tentatives par défaut, suppose bash existant -f__sudo(){ # 23/12/2017 - local nb=2 sudo isudo toBash + # $@=cmd à lancer en root avec su ou sudo. si $@ contient :x: x=nombre de tentatives, sinon 2 tentatives par défaut + # si bash inexistant, return 2 +f__sudo(){ # 14/01/2018 + local nb sudo isudo toBash options type -p bash &>/dev/null && toBash=$( type -p bash ) || return 2 # sudo --shell bash équivalent su ? @@ -141,9 +142,16 @@ f__sudo(){ # 23/12/2017 else sudo="su --shell $toBash --preserve-environment -c " fi - [ "$2" ] && nb=$(( "$2" )) + if [[ "$@" =~ :??: ]]; then + nb="$@" + nb=${nb#*:} + nb=${nb%:*} + else + nb=2 + fi + options=${@//:$nb:/ } for (( isudo=1 ; isudo<="$nb" ; isudo++ )); do - $sudo " $1" + $sudo " $options" [ "$?" == 0 ] && break [ "$isudo" == "$nb" ] && return 1 done diff --git a/scripts/getIp_changelog.md b/scripts/getIp_changelog.md index 9c28ede..3cb461c 100644 --- a/scripts/getIp_changelog.md +++ b/scripts/getIp_changelog.md @@ -1,6 +1,10 @@ # changelog getIp +## getIp 2.5.0 14/01/2018 + +* révision: f_sudo, format nombre de tentatives et options appel possibles > 1 + ## getIp 2.4.0 12/01/2018 * fix: correction commentaire fscript_get_version