Wireshark-dev: Re: [Wireshark-dev] Wireshark-dev] Linking error tfshark
From: Jeff Morriss <jeff.morriss.ws@xxxxxxxxx>
Date: Sat, 11 Jan 2014 15:40:23 -0500
On 01/11/2014 03:05 PM, mmann78@xxxxxxxxxxxx wrote:
Patch committed to rev 54697.
The issue with tfshark -V option isn't the option itself, its the
OPTSTRING string.  I stripped it down from tshark (removing options
that shouldn't be supported in tfshark) and apparently "broke" the
string pattern so that getopt isn't parsing the options correctly.  As a
test, I restored it to the current tshark OPTSTRING and the -V option
worked just fine.
Can someone point me to where I can understand the OPTSTRING syntax?
The :'s seem arbitrary to me.

man -s 3 getopt ?

A bit from the Linux version:

       optstring is a string containing the legitimate option characters.   If
       such  a  character is followed by a colon, the option requires an argu‐
       ment, so getopt() places a pointer to the following text  in  the  same
       argv-element,  or  the  text  of the following argv-element, in optarg.
       Two colons mean an option takes an optional arg; if there  is  text  in
       the  current  argv-element  (i.e.,  in the same word as the option name
       itself, for example, "-oarg"), then it is returned in optarg, otherwise
       optarg is set to zero.  This is a GNU extension.  If optstring contains
       W followed by a semicolon, then -W foo is treated as  the  long  option
       --foo.  (The -W option is reserved by POSIX.2 for implementation exten‐
       sions.)  This behavior is a GNU extension, not available with libraries
       before glibc 2.