<div dir="ltr">I didn't know that -- would work. The documentation didn't mention that.<div><br></div><div>The line "<span style="font-family:arial,sans-serif;font-size:13px">*) makepkg_args="$makepkg_args -$arg $OPTARG" ;;" is still wrong though as doing "--" will end getopt and then makepkg is called with </span><font face="arial, sans-serif">${*:$OPTIND} meaning that the parameters aren't handled by the getopts loop. Instead, how about this patch? It fixes the usage and removes the broken line.</font></div>

<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><div>---</div><div> <a href="http://makechrootpkg.in">makechrootpkg.in</a> | 3 +--</div><div> 1 file changed, 1 insertion(+), 2 deletions(-)</div>

<div><br></div><div>diff --git a/<a href="http://makechrootpkg.in">makechrootpkg.in</a> b/<a href="http://makechrootpkg.in">makechrootpkg.in</a></div><div>index d03b703..fc17b8a 100644</div><div>--- a/<a href="http://makechrootpkg.in">makechrootpkg.in</a></div>

<div>+++ b/<a href="http://makechrootpkg.in">makechrootpkg.in</a></div><div>@@ -35,7 +35,7 @@ src_owner=${SUDO_USER:-$USER}</div><div> usage() {</div><div> <span class="" style="white-space:pre">   </span>echo "Usage: ${0##*/} [options] -r <chrootdir> [--] [makepkg args]"</div>

<div> <span class="" style="white-space:pre">   </span>echo ' Run this script in a PKGBUILD dir to build a package inside a'</div><div>-<span class="" style="white-space:pre">     </span>echo ' clean chroot. All unrecognized arguments passed to this script'</div>

<div>+<span class="" style="white-space:pre">   </span>echo ' clean chroot. All arguments passed to this script after --'</div><div> <span class="" style="white-space:pre">        </span>echo ' will be passed to makepkg.'</div>

<div> <span class="" style="white-space:pre">   </span>echo ''</div><div> <span class="" style="white-space:pre">   </span>echo ' The chroot dir consists of the following directories:'</div><div>@@ -78,7 +78,6 @@ while getopts 'hcur:I:l:nTD:d:' arg; do</div>

<div> <span class="" style="white-space:pre">           </span>l) copy="$OPTARG" ;;</div><div> <span class="" style="white-space:pre">            </span>n) run_namcap=true; makepkg_args="$makepkg_args -i" ;;</div><div> <span class="" style="white-space:pre">          </span>T) temp_chroot=true; copy+="-$$" ;;</div>

<div>-<span class="" style="white-space:pre">           </span>*) makepkg_args="$makepkg_args -$arg $OPTARG" ;;</div><div> <span class="" style="white-space:pre">        </span>esac</div><div> done</div><div> </div><div>-- </div>

<div>1.9.0</div><div><br></div></font></div><div><font face="arial, sans-serif"><br></font></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Mar 15, 2014 at 9:48 PM, Dave Reisner <span dir="ltr"><<a href="mailto:d@falconindy.com" target="_blank">d@falconindy.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><p dir="ltr"><br>
On Mar 16, 2014 12:36 AM, "Joel Teichroeb" <<a href="mailto:joel@teichroeb.net" target="_blank">joel@teichroeb.net</a>> wrote:<br>
><br>
> 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.</p>



</div><p dir="ltr">This works just fine if you use the end-of-options delimiter to exit the getopts loop, e.g.:</p>
<p dir="ltr">makechrootpkg /path/to/chroot -- -R<br></p><div class="HOEnZb"><div class="h5">
<p dir="ltr">><br>
> [1] <a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/getopts.html" target="_blank">http://pubs.opengroup.org/onlinepubs/9699919799/utilities/getopts.html</a><br>
> ---<br>
>  <a href="http://makechrootpkg.in" target="_blank">makechrootpkg.in</a> | 4 ++--<br>
>  1 file changed, 2 insertions(+), 2 deletions(-)<br>
><br>
> diff --git a/<a href="http://makechrootpkg.in" target="_blank">makechrootpkg.in</a> b/<a href="http://makechrootpkg.in" target="_blank">makechrootpkg.in</a><br>
> index d03b703..7e5f8e8 100644<br>
> --- a/<a href="http://makechrootpkg.in" target="_blank">makechrootpkg.in</a><br>
> +++ b/<a href="http://makechrootpkg.in" target="_blank">makechrootpkg.in</a><br>
> @@ -66,7 +66,7 @@ usage() {<br>
>   exit 1<br>
>  }<br>
>  <br>
> -while getopts 'hcur:I:l:nTD:d:' arg; do<br>
> +while getopts ':hcur:I:l:nTD:d:' arg; do<br>
>   case "$arg" in<br>
>   h) usage ;;<br>
>   c) clean_first=true ;;<br>
> @@ -78,7 +78,7 @@ while getopts 'hcur:I:l:nTD:d:' arg; do<br>
>   l) copy="$OPTARG" ;;<br>
>   n) run_namcap=true; makepkg_args="$makepkg_args -i" ;;<br>
>   T) temp_chroot=true; copy+="-$" ;;<br>
> - *) makepkg_args="$makepkg_args -$arg $OPTARG" ;;<br>
> + *) makepkg_args="$makepkg_args -$OPTARG" ;;<br>
>   esac<br>
>  done<br>
>  <br>
> -- <br>
> 1.9.0</p>
</div></div></blockquote></div><br></div>