From 2ed270b4da3546c6653b34002481709c3aec96ca Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 28 Jan 2016 00:26:35 +1100 Subject: [PATCH] Fallback to using awk for line length on systems without 'wc -L' --- fetch | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fetch b/fetch index 0304d1a5..42078e4a 100755 --- a/fetch +++ b/fetch @@ -21,7 +21,7 @@ # Speed up script by not using unicode export LC_ALL=C -export LANG=C +export LANG=c export LANGUAGE=C @@ -1204,7 +1204,11 @@ getshuffle () { getascii () { # Get length of longest line - length="$(wc -L < "$ascii")" + length="$(wc -L 2>/dev/null < "$ascii")" + + # Fallback to using awk on systems without 'wc -L' + [ -z "$length" ] && \ + length="$(LC_ALL="en_US.UTF8" awk 'length>max{max=length}END{print max}' "$ascii")" # Set the text padding padding="\033[$((length + gap))C"