disk: Fix bash 3.2 incompatibility. Closes #1586
This commit is contained in:
parent
cb6f10d8f4
commit
2b39f58f74
19
neofetch
19
neofetch
|
@ -3586,7 +3586,7 @@ get_disk() {
|
|||
for disk in "${disks[@]}"; do
|
||||
# Create a second array and make each element split at whitespace this time.
|
||||
IFS=" " read -ra disk_info <<< "$disk"
|
||||
disk_perc=${disk_info[-2]/\%}
|
||||
disk_perc=${disk_info[${#disk_info[@]} - 2]/\%}
|
||||
|
||||
case $disk_percent in
|
||||
off) disk_perc=
|
||||
|
@ -3594,12 +3594,17 @@ get_disk() {
|
|||
|
||||
case $df_version in
|
||||
*befhikm*)
|
||||
disk="$((disk_info[-4]/1024/1024))G / $((disk_info[-5]/1024/1024))G"
|
||||
disk+="${disk_perc:+ ($disk_perc%)}"
|
||||
disk=$((disk_info[${#disk_info[@]} - 4] / 1024 / 1024))G
|
||||
disk+=" / "
|
||||
disk+=$((disk_info[${#disk_info[@]} - 5] / 1024/ 1024))G
|
||||
disk+=${disk_perc:+ ($disk_perc%)}
|
||||
;;
|
||||
|
||||
*)
|
||||
disk="${disk_info[-4]/i} / ${disk_info[-5]/i}${disk_perc:+ ($disk_perc%)}"
|
||||
disk=${disk_info[${#disk_info[@]} - 4]/i}
|
||||
disk+=" / "
|
||||
disk+=${disk_info[${#disk_info[@]} - 5]/i}
|
||||
disk+=${disk_perc:+ ($disk_perc%)}
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -3609,14 +3614,14 @@ get_disk() {
|
|||
;;
|
||||
|
||||
dir)
|
||||
disk_sub=${disk_info[-1]/*\/}
|
||||
disk_sub=${disk_sub:-${disk_info[-1]}}
|
||||
disk_sub=${disk_info[${#disk_info[@]} - 1]/*\/}
|
||||
disk_sub=${disk_sub:-${disk_info[${#disk_info[@]} - 1]}}
|
||||
;;
|
||||
|
||||
none) ;;
|
||||
|
||||
*)
|
||||
disk_sub=${disk_info[-1]}
|
||||
disk_sub=${disk_info[${#disk_info[@]} - 1]}
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
Reference in New Issue