- lines+=("$line")
- [[ ! ${line:10:11} == " " ]] && aclchar=true
- 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
- perm=0
- for (( x=0; x<=8; x++ )); do
- y=${line:$(( -1*x + 9 )):1}
- [[ $y == [tT] ]] && perm=$(( perm + 512 ))
- if [[ $y == [sS] ]]; then
- [[ $x == 3 ]] && perm=$(( perm + 1024 ))
- [[ $x == 6 ]] && perm=$(( perm + 2048 ))
- fi
- [[ $y != [-ST] ]] && perm=$(( perm + 2**x ))
- done
- if $aclchar; then
- y="${line:11}"
- 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
- middle=${y#*[^ ]* }
- size=${middle#*[^ ]* *[^ ]* }
- middle=${middle%"$size"}
- tail=${size#*[^ ]* }
- size=${size%"$tail"}
- declare -i sizePadding="${#size} - 1"
- size=( $size ) # remove spaces
- size=${size/.?/}
- # ignore the hardlinks that files/dirs always have
- if [[ ${line:0:1} == d ]]; then
- hardLinks=$(( hardLinks - 2 ))
+ # if we did want the first line, it would need to be stripped of non-printing chars:
+ #line=${line#$'\E[00m'}
+ # lines like "total 123M", we don't want
+ if [[ ! $line =~ ^total\ [0-9][^\ ]*$ ]]; then
+ lines+=("$line")
+ if ! [[ $line == [-dscbl][-r][-w][-xsS][-r][-w][-xsS][-r][-w][-xtT]* ]]; then
+ hardlinks=