On Wed, 12 Sep 2001, Micah Cowan wrote:
> What exactly was it that was inflexible about your curent getopt
> implementation?
The version that comes with DJGPP is the BSD version of getopt. All
"-x [optarg]" arguments are required to come before the arguments that do
not have any "-x" in front. For example, if I have:
while(1) {
int c = getopt(argc, argv, "-o:");
if(c == EOF) break;
switch(c) {
case 'o':
printf("Output filename should be \"%s\"\n", optarg);
break;
case 1:
printf("Input filename should be \"%s\"\n", optarg);
break;
}
}
And I type:
% myprog -o outfile infile
I'll get the desired behavior in both BSD and GNU implementations.
However, if I type:
% myprog infile -o outfile
then I'll get the desired behavior only in the GNU implementation.
I think the BSD implementation is the POSIX-compliant behavior, but I
don't want to think about which options should come before what when I use
my program and I don't want the other users of my program to think about
such details either, you know?
For now, I'm using the GNU implementation and I think things are alright
as long as the program doesn't get distributed. But if you *want* to
write your own version and release it with BSD license or public domain it
then I'll certainly appreciate it :)
Concerned for Peter and Rhonda,
-Mark
--
Mark K. Kim
http://www.cbreak.org/mark/
PGP key available upon request.