From 3d3fa4f0e9a77b2d47abf1f9d9361ccc635c30fb Mon Sep 17 00:00:00 2001 From: alanw Date: Tue, 2 May 2023 11:23:24 -0700 Subject: [PATCH 1/3] v1.1.11 - fixed center function --- functions | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/functions b/functions index f0285b3..4805f00 100644 --- a/functions +++ b/functions @@ -2,7 +2,7 @@ # pyr0ball script functions library # Initial Vars -functionsrev=1.1.10 +functionsrev=1.1.11 #scriptname="${BASH_SOURCE[0]##*/}" #rundir="${BASH_SOURCE[0]%/*}" #rundir_absolute=$(cd $rundir && pwd) @@ -337,18 +337,20 @@ boxseparator(){ # 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})" + #local padding=""; + #padding="$(printf '%0.1s' \ {1..100})" #padding=" " - printf '%*.*s %s %*.*s\n' 0 "$(((BOXWIDTH-2-${#1})/2))" "${padding}" "$1" 0 "$(((BOXWIDTH-1-${#1})/2))" "${padding}" + #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 -e "\r${ESC}[$(((BOXWIDTH-2-${#1})/2))C$1\r${ESC}[${BOXWIDTH}C" } # For printing spanned text, e.g. single-pair lists ($name...$title) spanner() { # 1: left-side-text, 2: right-side-text - local spanner=""; - eval printf -v spanner \'"%0.1s"\' "-"{1..$[$((BOXWIDTH-4))- 2 - ${#1} - ${#2}]} - printf "%s %s %s\n" "$1" "$spanner" "$2"; + local _spanner=""; + eval printf -v _spanner \'"%0.1s"\' "-"{1..$[$((BOXWIDTH-4))- 2 - ${#1} - ${#2}]} + printf "%s %s %s\n" "$1" "$_spanner" "$2"; } boxborder(){ From e4f3d628c0e558a6725a4b6768fd36d86f0fd472 Mon Sep 17 00:00:00 2001 From: alanw Date: Tue, 2 May 2023 12:57:26 -0700 Subject: [PATCH 2/3] fixed logs capturing empty lines and escape sequences --- functions | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/functions b/functions index 4805f00..28b7965 100644 --- a/functions +++ b/functions @@ -414,11 +414,14 @@ popdfail(){ } logger(){ - #$@ 2>&1 | tee >(ts "[$scriptname][%d-%m-%y %H_%M_%S]" > $logfile) # This version of prepend requires the 'ts' utility from 'moreutils' package $@ 2>&1 | tee >( while IFS= read -r line; do - _line=$(echo $line | sed "s,\x1B\[[0-9;]*[mK],,g" | tr -dc '[:print:]') - printf '[%s] %s\n' "${scriptname}][${prettyDate}" "$_line" + # strip any escaped strings for logging output + _line=$(echo $line | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | tr -dc '[:print:]') + # only print out non-empty lines to log + if [[ "$_line" != "" ]] ; then + printf '[%s] %s\n' "${scriptname}][${pretty_date}" "$_line" + fi done >> $logfile ) } From af88318630a0b23ffc76296ed98f3b79ed687209 Mon Sep 17 00:00:00 2001 From: Alan Weinstock Date: Tue, 2 May 2023 14:18:50 -0700 Subject: [PATCH 3/3] updated screenshot to latest --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 83ba8e2..f71a8ad 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,4 @@ With all of these tools combined, you can make powerful interactive scripts with run `./demo.sh` for example output -![image](https://user-images.githubusercontent.com/8482805/224919713-d1ec4723-1909-470d-93d6-1b7091de8de8.png) -![image](https://user-images.githubusercontent.com/8482805/224919800-2d4450e4-9fc7-4ef7-b432-9ccfd0278880.png) -![image](https://user-images.githubusercontent.com/8482805/224919970-0444b849-5959-49b5-a187-b6a214ccc84f.png) +![image](https://user-images.githubusercontent.com/8482805/235781738-f31481a8-946d-4051-9210-3df28687a19c.png)