# 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
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"}
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