]> wolfpit.net Git - tool/Arch-pacman/.git/commitdiff
makepkg: inline creation of checksum indenting
authorDave Reisner <dreisner@archlinux.org>
Tue, 3 Sep 2013 19:47:10 +0000 (15:47 -0400)
committerAllan McRae <allan@archlinux.org>
Wed, 18 Sep 2013 04:28:03 +0000 (14:28 +1000)
With some simple math and printf formatting tokens, we can create the
whitespace necessary for this without the need for a loop and string
concatentation.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
scripts/makepkg.sh.in

index 5a74b3ed0317a64d6e39f256a98bbdda1b7a3ca5..0825600f821427cfb997d7a234fc2403260911ef 100644 (file)
@@ -1146,14 +1146,8 @@ generate_checksums() {
                fi
 
                local ct=0
-               local numsrc=${#source[@]}
-               printf "%s" "${integ}sums=("
-
-               local i
-               local indent=''
-               for (( i = 0; i < ${#integ} + 6; i++ )); do
-                       indent="$indent "
-               done
+               local indentsz numsrc=${#source[@]}
+               printf "%s%n" "${integ}sums=(" indentsz
 
                local netfile
                for netfile in "${source[@]}"; do
@@ -1176,10 +1170,11 @@ generate_checksums() {
                                        ;;
                        esac
 
-                       (( ct )) && printf "%s" "$indent"
-                       printf "%s" "'$sum'"
-                       ct=$(($ct+1))
-                       (( $ct < $numsrc )) && echo
+                       # indent checksum on lines after the first
+                       printf "%*s%s" $(( ct ? indentsz : 0 )) '' "'$sum'"
+
+                       # print a newline on lines before the last
+                       (( ++ct < numsrc )) && echo
                done
 
                echo ")"