Fallback to using awk for line length on systems without 'wc -L'
This commit is contained in:
parent
6382f49afe
commit
2ed270b4da
1 changed files with 6 additions and 2 deletions
8
fetch
8
fetch
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
# Speed up script by not using unicode
|
# Speed up script by not using unicode
|
||||||
export LC_ALL=C
|
export LC_ALL=C
|
||||||
export LANG=C
|
export LANG=c
|
||||||
export LANGUAGE=C
|
export LANGUAGE=C
|
||||||
|
|
||||||
|
|
||||||
|
@ -1204,7 +1204,11 @@ getshuffle () {
|
||||||
|
|
||||||
getascii () {
|
getascii () {
|
||||||
# Get length of longest line
|
# 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
|
# Set the text padding
|
||||||
padding="\033[$((length + gap))C"
|
padding="\033[$((length + gap))C"
|
||||||
|
|
Loading…
Reference in a new issue