uptime: Fix shorthand off (#1564)

This commit is contained in:
Michael Straube 2020-09-25 13:36:46 +02:00 committed by GitHub
parent f74746d5b9
commit b83a48a60f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1433,7 +1433,7 @@ get_uptime() {
d="$((s / 60 / 60 / 24)) days" d="$((s / 60 / 60 / 24)) days"
h="$((s / 60 / 60 % 24)) hours" h="$((s / 60 / 60 % 24)) hours"
m="$((s / 60 % 60)) mins" m="$((s / 60 % 60)) minutes"
# Remove plural if < 2. # Remove plural if < 2.
((${d/ *} == 1)) && d=${d/s} ((${d/ *} == 1)) && d=${d/s}
@ -1447,20 +1447,24 @@ get_uptime() {
uptime=${d:+$d, }${h:+$h, }$m uptime=${d:+$d, }${h:+$h, }$m
uptime=${uptime%', '} uptime=${uptime%', '}
uptime=${uptime:-$s secs} uptime=${uptime:-$s seconds}
# Make the output of uptime smaller. # Make the output of uptime smaller.
case $uptime_shorthand in case $uptime_shorthand in
on) ;; on)
uptime=${uptime/ minutes/ mins}
uptime=${uptime/ minute/ min}
uptime=${uptime/ seconds/ secs}
;;
tiny) tiny)
uptime=${uptime/ days/d} uptime=${uptime/ days/d}
uptime=${uptime/ day/d} uptime=${uptime/ day/d}
uptime=${uptime/ hours/h} uptime=${uptime/ hours/h}
uptime=${uptime/ hour/h} uptime=${uptime/ hour/h}
uptime=${uptime/ mins/m} uptime=${uptime/ minutes/m}
uptime=${uptime/ min/m} uptime=${uptime/ minute/m}
uptime=${uptime/ secs/s} uptime=${uptime/ seconds/s}
uptime=${uptime//,} uptime=${uptime//,}
;; ;;
esac esac