help-bash
[Top][All Lists]
Advanced

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

Re: Handling getopt for option without optional argument value


From: Greg Wooledge
Subject: Re: Handling getopt for option without optional argument value
Date: Fri, 23 Jul 2021 14:37:55 -0400

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]