Fix issues with uptime on OSX and BSD

This commit is contained in:
Dylan 2016-04-29 09:42:58 +10:00
parent fb2ff8dead
commit f8c350cbff

View file

@ -591,22 +591,22 @@ getuptime () {
days=$((uptime / 86400)) days=$((uptime / 86400))
# Format the output like Linux's "uptime -p" cmd. # Format the output like Linux's "uptime -p" cmd.
if [ "$mins" == 1 ]; then if [ "$mins" != 0 ]; then
uptime="$mins minute"
elif [ "$mins" != 0 ]; then
uptime="$mins minutes" uptime="$mins minutes"
else
uptime="$mins minute"
fi fi
if [ "$hours" == 1 ]; then if [ "$mins" != 0 ]; then
uptime="$hours hour, $uptime"
elif [ "$mins" != 0 ]; then
uptime="$hours hours, $uptime" uptime="$hours hours, $uptime"
else
uptime="$hours hour, $uptime"
fi fi
if [ "$days" == 1 ]; then if [ "$days" != 0 ]; then
uptime="$days day, $uptime"
elif [ "$days" != 0 ]; then
uptime="$days days, $uptime" uptime="$days days, $uptime"
else
uptime="$days day, $uptime"
fi fi
uptime="up $uptime" uptime="up $uptime"