From ff6489bff53f19713e2c76a351886bb094c2d317 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 1 Oct 2021 12:00:23 -0700 Subject: [PATCH] improve busybox awk compatibility --- sh/e | 2 ++ sh/similar | 8 +++----- sh/trunc | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sh/e b/sh/e index 278d856..30d6e4a 100755 --- a/sh/e +++ b/sh/e @@ -4,6 +4,8 @@ # NO_DASH # NO_ASH +# works with busybox awk. + e() { ### @- ### wrap around `$EDITOR` to run it as root if necessary. ### this still needs some work to detect root-owned directories. diff --git a/sh/similar b/sh/similar index 18c843e..f54472e 100755 --- a/sh/similar +++ b/sh/similar @@ -4,7 +4,7 @@ # YES_DASH # YES_ASH -# does not work with busybox awk (yet?) +# works with busybox awk. similar() { ### @- ### highlight adjacent lines up to the first inequivalent character. @@ -12,10 +12,8 @@ similar() { ### @- awk ' { i=0 - split($0,a,"") - split(L,b,"") - for (c in a) - if (a[c]==b[c]) i++ + for(c=1;c&2; return 1; } COLUMNS=${COLUMNS:-$(tput cols)} - awk -vL=${1:-$COLUMNS} '{e=length>L?"…":"";print substr($0,0,L-(e?1:0)) e}' + awk -vL=${1:-$COLUMNS} '{e=length()>L?"…":"";print substr($0,0,L-(e?1:0)) e}' } [ -n "${preload+-}" ] || trunc "$@"