Friday, April 30, 2021

Re: fetch_cmd.template: use getopts

On Thu, Apr 29, 2021 at 04:07:23PM +0200, Christian Weisgerber wrote:
> Marc Espie:
>
> > > Switch the argument parsing from the deprecated getopt to getopts.
> > >
> > Not before I see actual documentation pointing to getopts
> >
> > Specifically: I wasn't even aware getopts existed.
> >
> > It is a built-in in sh (ksh ?)
>
> It's a POSIX shell built-in, so no separate man page. It's documented
> in sh(1) and ksh(1).

It's fairly recent as a built-in apparently, it wasn't in OpenGroups 2017
or so.

> (Historically, it was introduced in AT&T ksh88, I think. POSIX
> then picked it up due to the inherent deficiencies of getopt. It
> was already in the Almquist shell when that one was imported into
> the CSRG repository in 1991 as 4.4BSD's sh. It has been the successor
> to the deprecated getopt for some thirty years.)
>
> > getopt(1) doesn't mention it as an alternative.
> >
> > Oh, and sh(1) doesn't contain any usable example.
>
> The go-to example is in the POSIX text.

Can we get our own example ?

Can we mention sh(1)'s getopts in getopt(1)'s manpage ?

No comments:

Post a Comment