[pacman-dev] [PATCH] Fix command line argument parsing in makepkg

Dan McGee dpmcgee at gmail.com
Tue May 20 15:54:27 EDT 2008


On Mon, May 19, 2008 at 10:54 AM, Sebastian Nowicki <sebnow at gmail.com> wrote:
> On some systems, namely Mac OSX, command line parsing simply does not
> work. It appears $@ gets altered at some stage. This patch uses $ARGLIST
> instead, which contains the actual command line arguments
>
> Signed-off-by: Sebastian Nowicki <sebnow at gmail.com>
> ---
-p and --forcever have required arguments. This patch still works with
those, correct? (Meaning it reads and uses the next arg for the value,
and does not attempt to parse the arg as a flag.)

>  scripts/makepkg.sh.in |    7 +++----
>  1 files changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index cc44c68..f56bcda 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -1143,8 +1143,8 @@ fi
>  eval set -- "$OPT_TEMP"
>  unset OPT_SHORT OPT_LONG OPT_TEMP
>
> -while true; do
> -       case "$1" in
> +for arg in ${ARGLIST[@]}; do
> +       case "$arg" in
>                # Pacman Options
>                --noconfirm)      PACMAN_OPTS="$PACMAN_OPTS --noconfirm" ;;
>                --noprogressbar)  PACMAN_OPTS="$PACMAN_OPTS --noprogressbar" ;;
> @@ -1180,10 +1180,9 @@ while true; do
>                -h|--help)        usage; exit 0 ;; # E_OK
>                -V|--version)     version; exit 0 ;; # E_OK
>
> -               --)               OPT_IND=0; shift; break;;
> +               --)               OPT_IND=0; continue; break;;
Is it just me, or does this make no sense at all (continue followed by
break)? And the problem now is our $@ is not properly shifted for this
flag to even do anything.

>                *)                usage; exit 1 ;; # E_INVALID_OPTION
>        esac
> -       shift
>  done
>
>  if [ "$HOLDVER" = "1" -a "$FORCE_VER" != "" ]; then
> --
I guess I'm thinking this is a well-intentioned patch, but should we
try to attack the faulty $@ problem instead?

-Dan




More information about the pacman-dev mailing list