This allows handling of args with whitespace and other nonsense to be
passed properly to makepkg. Contrived example:

  makechrootpkg -r /path/to/chroot -- --config "/path/to/some config"
---
 makechrootpkg.in | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/makechrootpkg.in b/makechrootpkg.in
index 5ed7390..3ec7be1 100644
--- a/makechrootpkg.in
+++ b/makechrootpkg.in
@@ -100,7 +100,7 @@ else
 fi
 
 # Pass all arguments after -- right to makepkg
-makepkg_args="$makepkg_args ${*:$OPTIND}"
+makepkg_args=("${@:OPTIND}")
 
 # See if -R was passed to makepkg
 for arg in "${@:OPTIND}"; do
@@ -256,8 +256,9 @@ EOF
 
        # This is a little gross, but this way the script is recreated every 
time in the
        # working copy
+       printf -v extra_args ' %q' "${makepkg_args[@]}"
        printf $'#!/bin/bash\n%s\n_chrootbuild %q %q' "$(declare -f 
_chrootbuild)" \
-               "$makepkg_args" "$run_namcap" >"$copydir/chrootbuild"
+               "$extra_args" "$run_namcap" >"$copydir/chrootbuild"
        chmod +x "$copydir/chrootbuild"
 }
 
@@ -320,7 +321,7 @@ _chrootbuild() {
                exit 1
        fi
 
-       sudo -u nobody makepkg $makepkg_args || exit 1
+       sudo -u nobody makepkg "$makepkg_args" || exit 1
 
        if $run_namcap; then
                pacman -S --needed --noconfirm namcap
-- 
1.9.2

Reply via email to