aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2015-06-04 08:59:16 +1200
committerTom Ryder <tom@sanctum.geek.nz>2015-06-04 08:59:16 +1200
commit117265c6df389e85383093beac4dac780f9b6fd8 (patch)
tree697f12f024a5f66309061c0d02d0d4d562b2e981
parent175663c87dfc0677146690fe0c80e2593450b341 (diff)
downloadnscaw-117265c6df389e85383093beac4dac780f9b6fd8.tar.gz
Use TIMEFORMAT rather than munge the output
-rwxr-xr-xnscaw8
1 files changed, 2 insertions, 6 deletions
diff --git a/nscaw b/nscaw
index c3decf1..befb6c7 100755
--- a/nscaw
+++ b/nscaw
@@ -55,14 +55,10 @@ username=$(whoami)
# Attempt to run command within a time wrapper
# <http://mywiki.wooledge.org/BashFAQ/032>
exec 3>&1 4>&2
-time=$( { time "$@" 1>&3 2>&4 ; } 2>&1) ; ret=$?
+TIMEFORMAT=$'real %3lR, user %3lU, sys %3lS\n' \
+ time=$( { time "$@" 1>&3 2>&4 ; } 2>&1) ; ret=$?
exec 3>&- 4>&-
-# Munge the time to make it palatable as a single line
-time=${time#$'\n'} # Strip leading newline
-time=${time//$'\n'/, } # Change all newlines to comma-space
-time=${time//$'\t'/ } # Change all tabs to spaces
-
# Decide return code and message based on command exit value
case $ret in
0)