diff --git a/functions b/functions index ef4778b..0334d8f 100644 --- a/functions +++ b/functions @@ -2,7 +2,7 @@ # pyr0ball script functions library # Initial Vars -functionsrev=1.1.14 +functionsrev=1.1.15 #scriptname="${BASH_SOURCE[0]##*/}" #rundir="${BASH_SOURCE[0]%/*}" #rundir_absolute=$(cd $rundir && pwd) @@ -524,6 +524,8 @@ install-dir() { done < <(find "$_source" -type f -print0) } +# Utilities + clone-repo(){ # git clone local _url=$1 @@ -534,11 +536,33 @@ clone-repo(){ run git clone --recurse-submodules $_url $_destination } +# Executes: grep "$1" | grep "$2" | grep "$3" | ... +chained-grep(){ + local pattern="$1" + if [[ -z "$pattern" ]]; then + cat + return + fi + + shift + grep -- "$pattern" | chained-grep "$@" +} + +# Remove leading/trailing whitespace +trim() { + local var=$1 + var="${var#"${var%%[![:space:]]*}"}" + var="${var%"${var##*[![:space:]]}"}" + printf '%s' "$var" +} + ctrl_c(){ echo -e "\n" fail "User interrupted with Ctrl-C" } +# Cosmetics + prbl-logo(){ echo -e \ " @@ -678,7 +702,7 @@ spinstart() { sstop=false tput civis sc=0 - while [[ $sstop == false ]] ; do + until [[ $sstop != false ]] ; do for i in "${FRAME[@]}" ; do printf "\b${FRAME:sc++:1}" ((sc==${#FRAME})) && sc=0 @@ -711,6 +735,8 @@ printf "\rProgress : [${_done// /#}${_left// /-}] ${_progress}%%" } +# Menu functions + # Renders a text based list of options that can be selected by the # user using up, down and enter keys and returns the chosen option. # @@ -976,6 +1002,10 @@ vercomp() { return 0 } +check-prbl-version(){ + vercomp +} + compare-versions() { vercomp $1 $2 case $? in