diff options
author | Dave Reisner <d@falconindy.com> | 2010-06-11 14:47:10 -0400 |
---|---|---|
committer | Dave Reisner <d@falconindy.com> | 2010-06-11 15:03:08 -0400 |
commit | bb961954d1da2d84daf3e6717f75d3d897c9115d (patch) | |
tree | 3b4f34b509222b3c782575babe0141e0c3cd199d | |
parent | 0fbbe1fbf789988fbc50de992827e6af7afa231e (diff) | |
download | squashfu-bb961954d1da2d84daf3e6717f75d3d897c9115d.tar.gz |
use PE instead of awk and get rid of some subshells
-rwxr-xr-x | squashfu | 21 |
1 files changed, 8 insertions, 13 deletions
@@ -307,33 +307,28 @@ action_rollback () { action_report () { info "SquashFu Usage Report" - echo # Enumerate bins, sort date order, print human readable create date and size pushd "$BINS_DIR" &>/dev/null - OIFS=$IFS;IFS=${IFS}$':' # Collect all data into an array to 'preload' it. Index 0 is the entire # folder. The following indicies correspond to the bin number of that index - printf "%30s\r" ".: Loading :." >&2 - IFS=$'\n' read -r -d $'\0' -a data < <(du -csh . * 2>/dev/null | sort -n -k2) - for d in "${data[@]}"; do - local bin=${d#*[[:space:]]} - local size=${d%[[:space:]]*} + printf "\n%30s\r" ".: Loading :." >&2 + + while read size bin; do case ${bin} in 'total') total=$size; continue ;; '.') DATA[0]=$size ;; *) DATA[${bin}]=$size ;; esac - done + done < <(du -csh . * 2>/dev/null | sort -n -k2) printf "%30s\r" "" >&2 printf "%10s\t%25s\t%7s\n" "Bin ID" "Date Created" "Size" - grep -vE "^[\t ]*$" "$BINVENTORY" | sort -r -t: -k2 -n | while read bin stamp; do - printf "%10d\t%25s\t%7s\n" "$bin" \ - "$(date --rfc-3339=seconds --date="@$stamp")" \ - "${DATA[$bin]}" - done + OIFS=$IFS;IFS=${IFS}$':' + while read bin stamp; do + printf "%10d\t%25s\t%7s\n" "$bin" "$(date --rfc-3339=seconds --date="@$stamp")" "${DATA[$bin]}" + done < <(grep -v "^[[:space:]]*$" "$BINVENTORY" | sort -nr -t':' -k2) IFS=$OIFS printf "%10s\t%25s\t%7s\n" "" "Incremental Total" "${DATA[0]}" |