Browse Source

utility: Use Zsh native mechanism to detect GNU 'du'

Skip additional call to `grep` and use Zsh native mechanism to detect
GNU version of `du`.

Further, Remove redundant `function` clause as per Prezto convention.
master
Indrajit Raychaudhuri 4 years ago committed by Indrajit Raychaudhuri
parent
commit
8ea33ed07a
  1. 8
      modules/utility/functions/dut

8
modules/utility/functions/dut

@ -6,10 +6,11 @@ @@ -6,10 +6,11 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
function dut {
# function dut {
(( $# == 0 )) && set -- *
if grep -q -i 'GNU' < <(du --version 2>&1); then
if [[ ${(@M)${(f)"$(du --version 2>&1)"}:#*GNU *} ]]; then
du -khsc "$@" | sort -h -r
else
local line size name
@ -22,6 +23,5 @@ function dut { @@ -22,6 +23,5 @@ function dut {
printf "%9.1LfM %s\n" "$size" "$name"
done < <(du -kcs "$@") | sort -n -r
fi
}
dut "$@"
# }

Loading…
Cancel
Save