getopt does not parse optional arguments to parameters

Although not mentioned in glibc documentation or getopt man page, optional arguments to long style command line parameters require ‘equals sign’ (=). Space separating the optional argument from the parameter does not work.

An example run with the test code:

$ ./respond --praise John
Kudos to John
$ ./respond --praise=John
Kudos to John
$ ./respond --blame John
You suck !
$ ./respond --blame=John
You suck , John!

Leave a Comment