From 2dea28ea2a8e04d0eb8ab25117390ac8745cc9f8 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 26 Aug 2016 11:10:55 +1000 Subject: [PATCH] Fix awk bug on openwrt --- neofetch | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index 064e042e..74ab9b6b 100755 --- a/neofetch +++ b/neofetch @@ -1869,14 +1869,16 @@ getascii() { ascii_strip="${ascii_strip//'\\'/ }" ascii_strip="${ascii_strip//'\'}" - # Get ascii file size in rows/cols - ascii_size="$(awk 'END {printf NR " "}length>max{max=length}END{printf max}' <<< "$ascii_strip")" - lines="${ascii_size/ *}" - ascii_length="${ascii_size/$lines}" + # Get lines/columns of the ascii file in pure bash. + ascii_length=0 + lines=1 + while IFS='\n' read -r line 2>/dev/null; do + [ ${#line} -gt "$ascii_length" ] && ascii_length=${#line} + lines=$((lines+=1)) + done <<< "$ascii_strip" padding="\033[$((ascii_length + gap))C" printf "%b%s" "$print" - export LC_ALL=C }