New uptime formatting

This commit is contained in:
Dylan 2016-04-29 09:52:47 +10:00
parent b193b9e5d5
commit a2712b6333

View file

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