Re: getopt and Solaris 10

Derek Price <[email protected]> Thu, 05 May 2005 14:28:30 -0400
Newsgroups gmane.comp.lib.gnulib.bugs,gmane.comp.version-control.cvs.bugs
Organization Get CVS Support from Ximbiot <http://ximbiot.com>!
Message-ID <[email protected]>
James Youngman wrote:

>On Thu, May 05, 2005 at 01:34:24PM -0400, Derek Price wrote:
>
>  
>
>>Apparently Solaris 10 includes a getopt.h and appears to be GNU getopt
>>by all the tests in getopt.m4.  Unfortunately, it doesn't support "+" as
>>the first character of the option string.  
>>    
>>
>
>But surely we would now regard that usage as obsolete now?  It's been
>replaced by "--" hasn't it?
>  
>

CVS still makes use of it bacause we can parse a line like:

   cvs -fq -d /cvsroot checkout -P -d newname module

and getopt with a "+" as the first character of the option string kindly
stops when it reaches the CVS command "checkout".  We can then dump
everything up to optind:

    argc -= optind;
    argv += optind;
    if (argc < 1)
        usage (usg);

and reuse getopt, with a new option string, to parse the arguments to
checkout.  I don't think users would appreciate having to preceded all
CVS commands with a "--" argument.

   cvs -fq -d /cvsroot -- checkout -P -d newname module
   cvs -fq -d /cvsroot -- update

It's a bit redundant.

Regards,

Derek