On Mar 16, 2014 12:36 AM, "Joel Teichroeb" <joel@teichroeb.net> wrote:
>
> Currently, if a user has extra arguments on the end of their makechrootpkg command it prints an error and does not add those arguments to the makepkg command line as expected. As far as I can tell it would have never worked this way because according to the specifications for getopts[1] if there is no ":" at the start of the argument list $OPTARG will not be set and $arg will be set to "?", but if there is a ":" $OPTARG will be set to the unknown argument. Unfortunately this means we can not easily get the argument to an unknown option.This works just fine if you use the end-of-options delimiter to exit the getopts loop, e.g.:
makechrootpkg /path/to/chroot -- -R
>
> [1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/getopts.html
> ---
> makechrootpkg.in | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/makechrootpkg.in b/makechrootpkg.in
> index d03b703..7e5f8e8 100644
> --- a/makechrootpkg.in
> +++ b/makechrootpkg.in
> @@ -66,7 +66,7 @@ usage() {
> exit 1
> }
>
> -while getopts 'hcur:I:l:nTD:d:' arg; do
> +while getopts ':hcur:I:l:nTD:d:' arg; do
> case "$arg" in
> h) usage ;;
> c) clean_first=true ;;
> @@ -78,7 +78,7 @@ while getopts 'hcur:I:l:nTD:d:' arg; do
> l) copy="$OPTARG" ;;
> n) run_namcap=true; makepkg_args="$makepkg_args -i" ;;
> T) temp_chroot=true; copy+="-$" ;;
> - *) makepkg_args="$makepkg_args -$arg $OPTARG" ;;
> + *) makepkg_args="$makepkg_args -$OPTARG" ;;
> esac
> done
>
> --
> 1.9.0