Subject: Re: sysv ps(1) implementation [was: ps(1) sysv silliness]
To: Andrew Brown <>
From: Simon Burge <>
List: tech-userlevel
Date: 06/12/2000 03:24:20
Andrew Brown wrote:

> >> About supporting both BSD and System V style options in a single
> >> executable: please take into consideration that there are at least
> >> three command line options (-e, -p, -u) whose use differs between
> >> 'our' BSD implementation and System V.
> >
> >The options are currently handled by two different getopt loops, so this
> >isn't a problem.  FWIW, "aegjloptuU" appear in both...
> seems to me that it doesn't need to be so.  you ought to be able to
> have one big getopt loop that handled all switched (unless there are
> options that require args in one that conflict with non-argument
> switches in the other (hmm...'u' comes to mind).
>    behavior=BSD;
>    while (ch = getopt(argc, argv, "...reallylonglist...")) {
>    switch (ch) {
>    case 'B': behavior=BSD; break;
>    case 'V': behavior=SYSV (or whatever); break;
>    ...
>    }
>    if (behavior==SYSV) {
> 	   complain about various non-sysv options...
>    }
>    else {
> 	   complain about various non-bsd options...
>    }
>    do stuff

It's not really that simple.  For example, the common options "egjluU"
are handled differently and "aopt" are the same.  You'd also need to
remember which options had been specifid to do the "complain about..."
bit.  Plus I've already done it with the separate getopts :-)