Disk: Detect df version instead of detecting df per OS

This commit is contained in:
Muhammad Herdiansyah 2017-05-12 23:31:38 +07:00
parent ff3f0198d7
commit ea1f853c2a
1 changed files with 9 additions and 9 deletions

View File

@ -1803,13 +1803,13 @@ get_disk() {
type -p df >/dev/null 2>&1 || \ type -p df >/dev/null 2>&1 || \
{ err "Disk requires 'df' to function. Install 'df' to get disk info."; return; } { err "Disk requires 'df' to function. Install 'df' to get disk info."; return; }
# Get "df" flags. # Get "df" version.
case "$os" in df_version="$(df --version 2>&1)"
"Haiku") err "Disk doesn't work on Haiku due to the non-standard 'df'"; return ;; case "$df_version" in
"Mac OS X") df_flags=(-P -h) ;; *"blocks"*) err "Your version of df cannot be used due to the non-standard flags" ; return ;; # Haiku
"AIX") df_flags=(-P -g) ;; # AIX unknown
"IRIX") df_flags=(-P -k) ;; # IRIX unknown
*) df_flags=(-h) ;; *) df_flags=(-P -h) ;;
esac esac
# Create an array called 'disks' where each element is a separate line from # Create an array called 'disks' where each element is a separate line from
@ -1828,8 +1828,8 @@ get_disk() {
disk_info=($disk) disk_info=($disk)
disk_perc="${disk_info[4]/'%'}" disk_perc="${disk_info[4]/'%'}"
case "$os" in case "$df_version" in
"IRIX") "IRIX") # To be changed
disk="$((disk_info[2]/1024/1024))G / $((disk_info[2]/1024/1024))G (${disk_perc}%)" disk="$((disk_info[2]/1024/1024))G / $((disk_info[2]/1024/1024))G (${disk_perc}%)"
;; ;;