From 2cd54829d381549b6eb7a18ec5d021cbc8012b61 Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Sat, 29 Jan 2022 13:09:11 -0300 Subject: [PATCH] Rewrite calcWidth() --- install.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 2027b1a..8bf6d6b 100755 --- a/install.sh +++ b/install.sh @@ -354,16 +354,16 @@ calcAndRun() { calcWidth() { str=$1; count=1; found=false; option=1 - for (( i = 0; i < ${#str}; i++ )); do - if [ "${str:$i:1}" = "\\" ] && [ "${str:$((i+1)):1}" = "n" ]; then + while IFS= read -r -N 1 c; do + if [[ "$c" == $'\n' ]]; then [ $count -ge $option ] && option=$count found=true count=-1 fi ((count++)) - done - [ $option -ge "$count" ] && count=option - echo $((count+3)) + done < <(echo -ne "$str") + [ $option -ge $count ] && count=option + echo $((count+4)) } calcHeight() {