fix unnecessary printing fallback, small refactor
authorIan Kelling <ian@iankelling.org>
Sun, 9 Apr 2017 06:36:43 +0000 (23:36 -0700)
committerIan Kelling <ian@iankelling.org>
Sun, 9 Apr 2017 06:36:43 +0000 (23:36 -0700)
ll-function

index eb04f916cf3a986ffb8d594efe72074c56d65bba..51f72ffec1a093571ffd6b139e1bfcf6e1c96b52 100644 (file)
@@ -82,36 +82,36 @@ EOF
     for index in "${!lines[@]}"; do
         line=${lines[index]}
         hardlinks=${hl[index]}
-        if ! [[ $line == [-a-ZA-Z][-r][-w][-xsS][-r][-w][-xsS][-r][-w][-xtT]* ]]; then
+        if [[ $line != [-a-zA-Z][-r][-w][-xsS][-r][-w][-xsS][-r][-w][-xtT]* ]]; then
             # line we don't understand
            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
-           middle=${y#*[^ ]* }
-           size=${middle#*[^ ]* *[^ ]* }
-           middle=${middle%"$size"}
-           tail=${size#*[^ ]* }
-           size=${size%"$tail"}
-           declare -i sizePadding="${#size} - 1"
-           size=( $size ) # remove spaces
-           size=${size/.?/}
-
-           printf "%s%4o%${hardlink_spacing}s%s%${sizePadding}s%s\n" \
-                  "${line:0:1}" $perm "$hardlinks" " $middle" "$size" " $tail"
+            continue
        fi
+       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
+       middle=${y#*[^ ]* }
+       size=${middle#*[^ ]* *[^ ]* }
+       middle=${middle%"$size"}
+       tail=${size#*[^ ]* }
+       size=${size%"$tail"}
+       declare -i sizePadding="${#size} - 1"
+       size=( $size ) # remove spaces
+       size=${size/.?/}
+
+       printf "%s%4o%${hardlink_spacing}s%s%${sizePadding}s%s\n" \
+              "${line:0:1}" $perm "$hardlinks" " $middle" "$size" " $tail"
     done
 }