On Fri, Aug 16, 2013 at 10:49:24AM +0200, Florian Bruhin wrote: > * Mono <mono _at_ posteo _dot_ de> [2013-08-16 08:04:56 +0200]: > > how about having an sed command insert -W interactive during > > installation, only if mawk is detected? hmm, just an idea. > > That sounds kind-of hacky, but it gave me a nice idea. What about > something like this, in the actual script: > > if awk -Wv 2>/dev/null | head -1 | grep -q '^mawk'; then > awk_args=('-W' 'interactive') > else > awk_args=() > fi > # ... > awk "${awk_args[@]}" ... Or even faster: if awk -Wv 2>/dev/null | head -1 | grep -q '^mawk'; then uniq_linebuffered() { awk -W interactive '$0 != l { print ; l=$0 ; fflush(); }' "$@" } else uniq_linebuffered() { awk '$0 != l { print ; l=$0 ; fflush(); }' "$@" } fi > Though I should probably test how fflush() actually behaves for all > these versions of awk. Yes. Maybe there is some Posix specification. Thorsten
Attachment:
pgpGY_XPrMDtP.pgp
Description: PGP signature