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