summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Wright <fw@fwright.net>2016-02-22 15:53:36 -0800
committerJon Schlueter <jschlueter@redhat.com>2016-02-23 06:43:07 -0500
commit17d126f75a8f6229d98a73d3a7932cd95d04b4cf (patch)
treeaf77b67c35e1d3d191e032f054baf9e3d2c0505a
parentf8597504e3d4868b7e250c73910dac990ed5f75f (diff)
downloadgpsd-17d126f75a8f6229d98a73d3a7932cd95d04b4cf.tar.gz
Fixes echo nonportability in regress-driver.
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. Signed-off-by: Jon Schlueter <jschlueter@redhat.com>
-rwxr-xr-xregress-driver5
1 files changed, 3 insertions, 2 deletions
diff --git a/regress-driver b/regress-driver
index f3b886ea..4289af2d 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}