Cleaner rewrite

This commit is contained in:
Dylan 2016-04-29 10:25:46 +10:00
parent 08e8113c8b
commit d47c126144
1 changed files with 7 additions and 15 deletions

View File

@ -591,32 +591,24 @@ getuptime () {
days=$((uptime / 86400)) days=$((uptime / 86400))
case "$minutes" in case "$minutes" in
1) minutes="1 minute" ;; 1) uptime="1 minute" ;;
0) unset minutes ;; 0) unset minutes ;;
*) minutes="$minutes minutes" ;; *) uptime="$minutes minutes" ;;
esac esac
case "$hours" in case "$hours" in
1) hours="1 hour" ;; 1) uptime="1 hour, $uptime" ;;
0) unset hours ;; 0) unset hours ;;
*) hours="$hours hours" ;; *) uptime="$hours hours, $uptime" ;;
esac esac
case "$days" in case "$days" in
1) days="1 day" ;; 1) uptime="1 day, $uptime" ;;
0) unset days ;; 0) unset days ;;
*) days="$days days" ;; *) uptime="$days days, $uptime" ;;
esac esac
[ ! -z "$hours" ] && \ uptime="up $uptime"
[ ! -z "$minutes" ] && \
hours+=","
[ ! -z "$days" ] && \
[ ! -z "$hours" ] && \
days+=","
uptime="up $days $hours $minutes"
;; ;;
esac esac