From 5b9984df80b233f59ba84ac947872c61cc93b3f7 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Wed, 24 May 2023 19:50:50 -0700 Subject: [PATCH 1/2] fixed recursion in function --- functions | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/functions b/functions index 96f86ad..23e5893 100644 --- a/functions +++ b/functions @@ -412,10 +412,10 @@ run-and-log(){ logger(){ if [ ! -z $logfile ] ; then if [ ! -f $logfile ] ; then - run mkdir -p ${rundir%/*} + #run mkdir -p ${rundir%/*} touch $logfile fi - $@ 2>&1 | tee >( + "$@" 2>&1 | tee >( while IFS= read -r line; do # strip any escaped strings for logging output _line=$(echo $line | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | tr -dc '[:print:]') @@ -513,7 +513,9 @@ install-dir() { success(){ _line="$@" echo -e "\n" - boxborder "${scriptname} ${grn}SUCCESS${dfl} ${_line}" + boxtop + boxline "${scriptname} ${grn}SUCCESS${dfl} ${_line}" + boxbottom exit 0 } From 2fac6ba3a335a89acc07287928446bd6b92169d1 Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Sat, 27 May 2023 13:40:39 -0700 Subject: [PATCH 2/2] fixed center function --- functions | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/functions b/functions index 06aeaf8..f9d2e71 100644 --- a/functions +++ b/functions @@ -374,10 +374,12 @@ subboxborder(){ # For printing center-justified text. To change the padding character, replace the ' ' <~~ whitespace in front of the '{' in the padding variable center(){ - #local padding=""; - padding="$(printf '%0.1s' \ {1..100})" - #padding=" " - printf '%*.*s %s %*.*s\n' 0 "$(((BOXWIDTH-2-${#1})/2))" "${left_border}${padding}" "$1" 0 "$(((BOXWIDTH-1-${#1})/2))" "${padding}${right_border}" + local padding="" + padding="$(printf ' %.0s' {1..100})" + local string_length=${#1} + local padding_length=$(( (BOXWIDTH - 2 - string_length) / 2 )) + printf "%s%s %s %s%s\n" "$left_border" "${padding:0:padding_length}" "$1" "${padding:0:padding_length}" "$right_border" + #printf '%*.*s %s %*.*s\n' 0 "$(((BOXWIDTH-2-${#1})/2))" "${left_border}${padding}" "$1" 0 "$(((BOXWIDTH-1-${#1})/2))" "${padding}${right_border}" #printf "%s %s %s %s %s\n" "$left_border" "$padding" "$1" "$padding" "$right_border"; #echo -en "\r${ESC}[$(((BOXWIDTH-${#1})/2))C$@\r${ESC}[${BOXWIDTH}C\n" } @@ -588,7 +590,7 @@ trim() { strip-html-tags() { local input="$1" - local stripped=$(echo "$input" | sed 's/<[^>]*>//g') + local stripped=$(echo "$input" | sed 's/<[^>]*>//g' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') echo "$stripped" }