From: David Levine Date: Thu, 9 Jan 2014 00:23:10 +0000 (-0600) Subject: Detect whether or not to use -n with tail in build_nmh. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/b84d3f849be5d858d8348a741f6b8ccd881509fe Detect whether or not to use -n with tail in build_nmh. Synched that to uip/mhmail. --- diff --git a/docs/contrib/build_nmh b/docs/contrib/build_nmh index cb2265cb..b00ad90f 100755 --- a/docs/contrib/build_nmh +++ b/docs/contrib/build_nmh @@ -119,6 +119,11 @@ finddir() { esac } +#### Figure out whether or not to use -n with tail. +case `printf 'OK\n' | tail -n 1 2>&1` in + OK) tail='tail -n ' ;; + *) tail='tail -' ;; +esac if install-mh -check >/dev/null 2>&1; then # Determine config options from installed nmh. @@ -290,7 +295,7 @@ if [ $status -eq 0 ]; then echo "$tests_summary" >>"$logfile" echo '===================' >>"$logfile" [ "$check" = distcheck ] && \ - echo "$checkoutput" | tail -n 4 >>"$logfile" + echo "$checkoutput" | ${tail}4 >>"$logfile" fi if [ $status -eq 0 ]; then diff --git a/uip/mhmail b/uip/mhmail index a00d7cc9..916732d8 100755 --- a/uip/mhmail +++ b/uip/mhmail @@ -50,11 +50,10 @@ finddir() { bindir=`finddir $0` nmhbindir=`cd "$bindir" && pwd` -if printf 'OK\n' | tail -n 1 2>&1 | grep OK >/dev/null; then - tail='tail -n' -else - tail='tail -' -fi +case `printf 'OK\n' | tail -n 1 2>&1` in + OK) tail='tail -n ' ;; + *) tail='tail -' ;; +esac #### Checks for missing mandatory arguments.