From 269733e64ff0b5e39f7882d198c9956b770d60ce Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Wed, 28 May 2014 11:10:47 -0700 Subject: [PATCH] small formatting fix, refactor, remove 1st line --- ll-function | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/ll-function b/ll-function index 2776ff4..f2ccb1c 100644 --- a/ll-function +++ b/ll-function @@ -33,17 +33,17 @@ ll() { # or blank for no other kind of acl # I don't want to see this generally. while read line; do - lines+=("$line") - [[ ! ${line:10:11} == " " ]] && aclchar=true + if $first; then + first=false + else + # if we did want the first line, it would need to be stripped of non-printing chars: + # line=${line#$'\E[00m'} + lines+=("$line") + [[ ! ${line:10:1} == " " ]] && aclchar=true + fi done< <( "$binls" -lAh --color=always "--time-style=+%m-%d %Y %m-%d %I:%M %P" "$@" ) - for line in "${lines[@]}"; do - # very first line starts with some non printing chars - if $first; then - line=${line#$'\E[00m'} - first=false - fi if ! [[ $line == [-dscbl][-r][-w][-xsS][-r][-w][-xsS][-r][-w][-xtT]* ]]; then printf "%s\n" "$line" else @@ -62,9 +62,10 @@ ll() { else y="${line:10}" fi - t="${y#"${y%%[![:space:]]*}"}" # remove any initial spaces - hardLinks="${t%%[[:space:]]*}" # remove everything beyond first word - z=$(( ${#y} - ${#t} + ${#hardLinks} )) # length of hardlink string including padding + initial_space="${y%%[![:space:]]*}" + hardLinks="${y#$initial_space}" # remove any initial spaces + hardLinks="${hardLinks%%[[:space:]]*}" # remove everything beyond first word + hardLink_spacing=$(( ${#initial_space} + ${#hardLinks} )) # length of hardlink string including padding middle=${y#*[^ ]* } size=${middle#*[^ ]* *[^ ]* } middle=${middle%"$size"} @@ -80,7 +81,7 @@ ll() { hardLinks=$(( hardLinks - 1 )) fi [[ $hardLinks == 0 ]] && hardLinks= - printf "%s%4o%${z}s%s%${sizePadding}s%s\n" \ + printf "%s%4o%${hardLink_spacing}s%s%${sizePadding}s%s\n" \ "${line:0:1}" $perm "$hardLinks" " $middle" "$size" " $tail" fi done -- 2.30.2