help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Handling getopt for option without optional argument value


From: lisa-asket
Subject: Handling getopt for option without optional argument value
Date: Fri, 23 Jul 2021 21:19:53 +0200 (CEST)

Perhaps I could come up with something eventually.  But the requirement that

things will mork for all unix-like cases without requiring any tweaking would 

be remote, and most likely rejected.


From: Greg Wooledge <greg@wooledge.org>
To: help-bash@gnu.org
Subject: Re: Handling getopt for option without optional argument value
Date: 23/07/2021 20:37:55 Europe/Paris

Here are some examples of GNU programs written in a shell language
which have nontrivial option parsing. There may be other, even better,
examples out there. These were simply the first few that I found.


1) gettextize from the gettext project.

https://git.savannah.gnu.org/cgit/gettext.git/tree/gettext-tools/misc/gettextize.in#n232

Note: this is not the script's final form. It contains autoconf
macros that are expanded during the build process. However, that
does not affect the option parsing section.


2) nroff from the groff project.

https://git.savannah.gnu.org/cgit/groff.git/tree/src/roff/nroff/nroff.sh#n62


3) texi2dvi from the texinfo project.

https://git.savannah.gnu.org/cgit/texinfo.git/tree/util/texi2dvi#n1758


I hope you find these examples to be as illuminating as I did. In
particular, note that they are all unique, hand-written pieces of sh
code. They don't use getopt *or* getopts. In fact, most of them
are still written for the Bourne shell, not even adopting POSIX syntax
features, let alone bash features.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]