gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-dev] [PATCH 1/2] Fixes echo nonportability in regress-driver.


From: Fred Wright
Subject: [gpsd-dev] [PATCH 1/2] Fixes echo nonportability in regress-driver.
Date: Mon, 22 Feb 2016 15:53:36 -0800

Some implementations of the echo command (including the bash builtin
when invoked as '/bin/sh') don't implement the -n option, resulting in
a "-n Elapsed time:" line followed by the time on another line.  This
change eliminates the -n by constructing the elapsed time message as a
single line (since there's no fully portable way to suppress the
newline after an echo).

This also redirects the elapsed time message to stderr, for
consistency with the header messages.

TESTED:
Ran and observed correct output.
---
 regress-driver | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/regress-driver b/regress-driver
index f3b886e..4289af2 100755
--- a/regress-driver
+++ b/regress-driver
@@ -197,8 +197,9 @@ endtime=`date +"%s * 1000000000 + %N" | sed '/+ N/s///' 
2>/dev/null`
 
 if [ "$starttime" -a "$endtime" ]
 then
-    echo -n "Elapsed time: "
-    echo "scale=2; (${endtime} - ${starttime}) / 1000000000" | bc
+    # Avoid using -n here since some shells don't support it.
+    echo "Elapsed time:" \
+    $(echo "scale=2; (${endtime} - ${starttime}) / 1000000000" | bc) >&2
 fi
 
 rm -fr ${TMP}
-- 
2.7.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]