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