dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [MAN] Fix description of getopts when last argument reached
@ 2015-06-02 20:55 Felix Dietrich
  2015-06-11  6:34 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Felix Dietrich @ 2015-06-02 20:55 UTC (permalink / raw)
  To: dash

---
When I read the getopts description in the man-page I got stumped by the
following part:

    getopts optstring var

        [..]

        If there are no remaining arguments, getopts will set var to
        special option, “--”, otherwise, it will set var to “?”

        [..]

After I was unable to get getopts to store "--" in var, I asked for help
on comp.unix.shell [1] where it was pointed out to me that actually the
POSIX description of getopts [2] does not include a special option "--";
dash's behaviour of setting var to "?" after the last argument is
correct and that this is most likely an error in the documention.

In case this is not an error: Under what circumstances will var be set
to "--"?  Could you provide an example?

[1] https://groups.google.com/forum/#!topic/comp.unix.shell/BIR9dDgKZvg
[2] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/getopts.html

 src/dash.1 | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/dash.1 b/src/dash.1
index 693c970..832eae7 100644
--- a/src/dash.1
+++ b/src/dash.1
@@ -1402,14 +1402,9 @@ By specifying a colon as the first character of
 .Va optstring
 all errors will be ignored.
 .Pp
-A nonzero value is returned when the last option is reached.
-If there are no remaining arguments,
+After the last option
 .Ic getopts
-will set
-.Va var
-to the special option,
-.Dq -- ,
-otherwise, it will set
+will return a non-zero value and set
 .Va var
 to
 .Dq \&? .
-- 
2.1.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [MAN] Fix description of getopts when last argument reached
  2015-06-02 20:55 [MAN] Fix description of getopts when last argument reached Felix Dietrich
@ 2015-06-11  6:34 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2015-06-11  6:34 UTC (permalink / raw)
  To: Felix Dietrich; +Cc: dash

Felix Dietrich <felix.dietrich@sperrhaken.name> wrote:
> ---
> When I read the getopts description in the man-page I got stumped by the
> following part:
> 
>    getopts optstring var
> 
>        [..]
> 
>        If there are no remaining arguments, getopts will set var to
>        special option, “--”, otherwise, it will set var to “?”
> 
>        [..]
> 
> After I was unable to get getopts to store "--" in var, I asked for help
> on comp.unix.shell [1] where it was pointed out to me that actually the
> POSIX description of getopts [2] does not include a special option "--";
> dash's behaviour of setting var to "?" after the last argument is
> correct and that this is most likely an error in the documention.

Patch applied.  Thanks!
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-11  6:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-02 20:55 [MAN] Fix description of getopts when last argument reached Felix Dietrich
2015-06-11  6:34 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).