libpopt has numerous warts. This patch (for version 1.7) and this patch (for version 1.8) make the following improvements to it:
A minor grammatical error in the documentation has been corrected.
The documentation for the automatic --help and --usage facilities now correctly describes their actual operation, in addition to describing the further augmentations that this patch makes.
The original documentation stated that the automatic --help and --usage facilities write to standard error. In fact, in accordance with the GNU recommendations they write to standard output.
If and only if the output device is a terminal whose width can be obtained from the kernel, the help and usage messages are now word-wrapped to fit the actual width of the output device.
Originally, the width was fixed at 80 characters.
Word-wrapping of the usage message now correctly accounts for the possibility that "Usage:" may be translated into another language and thus have a length other than 6 characters.
Originally, the word-wrapping of the usage message assumed that "Usage:" was always 6 characters long.
The automatic --usage facility now no longer confusingly prints short options, that have an equivalent long option, twice.
Originally, because of faulty implementation, the automatic --usage facility would print short options twice, once when printing the combining short options en bloc and again when printing the individual long option, and thus end up printing things like this:
$lchfn --usage Usage: lchfn [-i?] [-i|--interactive] [-?|--help] [--usage] [OPTION...] [user]
Now, it prints:
$lchfn --usage Usage: lchfn [-i|--interactive] [-?|--help] [--usage] [OPTION...] [user]
The collection of combining short options for display in the automatic
--usage message has been greatly improved, eliminating the need
for completely unnecessary multiple calls to alloca()
within
recursive functions. The automatic --usage facility also now
longer confusingly prints the block of combining short options, that have
no long option, multiple times.
Originally, because of the faulty logic (which changed from version to version and which had different faults in different versions), the automatic --usage facility would end up printing things like this:
$rpm --usage | head -n 1 Usage: rpm [-aKfgpqV] [-aKfgpqVcdils] [-aKfgpqVcdilsaKfgpqV] [-aKfgpqVcdilsaKfgpqV] [-aKfgpqVcdilsaKfgpqVK] [-aKfgpqVcdilsaKfgpqVK] [-aKfgpqVcdilsaKfgpqVKi] [-aKfgpqVcdilsaKfgpqVKiv] [-aKfgpqVcdilsaKfgpqVKiv] [-aKfgpqVcdilsaKfgpqVKiv?] [-a|--all] [-f|--file] [-g|--group]
(Yes, it really would print all of that on one line! The faulty logic mucked up the word-wrapping, too. This is the specific faulty logic from popt 1.8.1-0.30, by the way.)
Now, it prints:
$rpm --usage | head -n 1 Usage: rpm [-a|--all] [-f|--file] [-g|--group] [-p|--package] [--specfile]
Hidden combining short options are no longer erroneously, despite being hidden, included in the automatic --usage message.
Non-combining short options, with no long option equivalent, are no longer displayed in the automatic --usage message with a syntax that doesn't actually work.
Originally, the automatic --help facility would print an = character after such options, even though an = character was not syntactically correct for short options and wouldn't actually work:
-f=filename script file to execute
Now, the syntax that is actually accepted for such options is printed:
-f filename script file to execute