From 36fe312ade2c43927c3fc87b13be1045e625e592 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Wed, 28 Feb 2018 16:32:42 +0200 Subject: [PATCH] __run_duration returns 0 when it can't calculate the command run duration (when the shell doesn't have support for PS0, like ksh). --- .bashrc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.bashrc b/.bashrc index 12c9d4b..0ca1efa 100644 --- a/.bashrc +++ b/.bashrc @@ -211,12 +211,16 @@ match_ssl_pair () { } __run_duration () { - # Assumes that $HOME/.prerun.$$ exists. - local endtime starttime - endtime="$(date +%s)" - starttime="$(cat "$HOME/.prerun.$$")" - rm "$HOME/.prerun.$$" - echo "$(( endtime - starttime ))" + if [ -f "$HOME/.prerun.$$" ] + then + local endtime starttime + endtime="$(date +%s)" + starttime="$(cat "$HOME/.prerun.$$")" + rm "$HOME/.prerun.$$" + echo "$(( endtime - starttime ))" + else + echo 0 + fi } __prerun () { -- GitLab