diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2015-06-04 08:59:16 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2015-06-04 08:59:16 +1200 |
commit | 117265c6df389e85383093beac4dac780f9b6fd8 (patch) | |
tree | 697f12f024a5f66309061c0d02d0d4d562b2e981 | |
parent | Remove unneeded quotes (diff) | |
download | nscaw-117265c6df389e85383093beac4dac780f9b6fd8.tar.gz nscaw-117265c6df389e85383093beac4dac780f9b6fd8.zip |
Use TIMEFORMAT rather than munge the output
-rwxr-xr-x | nscaw | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -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) |