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 <[email protected]>
---
 scripts/makepkg.sh.in | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 5a74b3e..2239913 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1149,12 +1149,6 @@ generate_checksums() {
                local numsrc=${#source[@]}
                printf "%s" "${integ}sums=("
 
-               local i
-               local indent=''
-               for (( i = 0; i < ${#integ} + 6; i++ )); do
-                       indent="$indent "
-               done
-
                local netfile
                for netfile in "${source[@]}"; do
                        local proto sum
@@ -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 ? ${#integ} + 6 : 0 )) '' "'$sum'"
+
+                       # print a newline on lines before the last
+                       (( ++ct < numsrc )) && echo
                done
 
                echo ")"
-- 
1.8.4


Reply via email to