[net.unix] getopt

ado@elsie.UUCP (Arthur David Olson) (10/19/85)

> Again, 'real' getopt will accept all of the above combinations of -s and -g
> above. . .

I don't know about you, but I write code that gets used on machines other than
the one I use.  I get to keep this in mind when I write the code.  If I make
use of something that's available on my machine and that isn't available on
some other machine, I'll regret it down the line.

From this perspective, the "getopt" that's been posted to the network is the
"real" getopt.  I know it'll be available on any machine my software goes to--
simply because I can put the posted version of getopt on the tape I send.  The
AT&T version of getopt is "unreal" from this perspective--there's nothing I can
do (legally) to guarantee that it will be available at the receiving end.  Of
course, there is something AT&T could do--put the source code for the "real"
getopt.c in the public domain.  Hint, hint.

As always, the contents of this article are entirely my own responsibility.
--
UNIX is an AT&T Bell Laboratories trademark.
--
	UUCP: ..decvax!seismo!elsie!ado    ARPA: elsie!ado@seismo.ARPA
	DEC, VAX and Elsie are Digital Equipment and Borden trademarks

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (10/20/85)

> ...  Of course, there is something AT&T could do--put the source code
> for the "real" getopt.c in the public domain.

They already did that.

ark@alice.UucP (Andrew Koenig) (10/21/85)

> From this perspective, the "getopt" that's been posted to the network is the
> "real" getopt.  I know it'll be available on any machine my software goes to--
> simply because I can put the posted version of getopt on the tape I send.  The
> AT&T version of getopt is "unreal" from this perspective--there's nothing I can
> do (legally) to guarantee that it will be available at the receiving end.  Of
> course, there is something AT&T could do--put the source code for the "real"
> getopt.c in the public domain.  Hint, hint.

The source code for the "real" getopt.c is available at no charge
from the Unix (TM) System Toolchest.  Dial (201) 522-6900 from your
1200 baud modem and log in as "guest" for further details.

frodo@wcom.UUCP (Jim Scardelis) (10/21/85)

> AT&T version of getopt is "unreal" from this perspective--there's nothing I can
> do (legally) to guarantee that it will be available at the receiving end.  Of
> course, there is something AT&T could do--put the source code for the "real"
> getopt.c in the public domain.  Hint, hint.

	The AT&T version of getopt(3c) is available for free, with free
sub-licensing from the AT&T Toolchest [(201) 522-6900, login: guest]. 
-- 
					Jim Scardelis, SA
					vax135!wcom!frodo

#include <favorite disclaimer>

campbell@maynard.UUCP (Larry Campbell) (10/21/85)

> > ...  Of course, there is something AT&T could do--put the source code
> > for the "real" getopt.c in the public domain.
> 
> They already did that.

They did?  Where can I get my copy?

-- 
Larry Campbell                     decvax!genrad
The Boston Software Works, Inc.                 \
120 Fulton St.                 seismo!harvard!wjh12!maynard!campbell
Boston MA 02109                         /       /
                                   ihnp4  cbosgd

ARPA: campbell%maynard.uucp@harvard.ARPA  (broken because of bugs at Harvard)
  or: maynard.UUCP:campbell@harvard.ARPA  (works now but try above if no joy)

peter@graffiti.UUCP (Peter da Silva) (10/22/85)

> > ...  Of course, there is something AT&T could do--put the source code
> > for the "real" getopt.c in the public domain.
> 
> They already did that.

Wasn't there just a debate on mod.std.c which came down to the fact that they
did not put it in the public domain after all? Would someone check their
archives & make sure?

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (10/22/85)

> > > ...  Of course, there is something AT&T could do--put the source code
> > > for the "real" getopt.c in the public domain.
> > 
> > They already did that.
> 
> They did?  Where can I get my copy?

In the paper "An Enhanced Getopt" by T.C. Jones & L.A. Kennedy
of AT&T Bell Labs, Summit NJ 07901.  If you can't get it from
the authors, stay tuned; someone at Seismo may post the code.

"The enhanced getopt(1) and getopt(3c) source code is being
published by AT&T Bell Laboratories to encourage adherence to
the command syntax standard and to satisfy requests from both
the /usr/group Standards Committee and our customers.  This
action is not a precedent since AT&T Bell Laboratories does
not plan on publishing any additional source code."

Incidentally, I strongly object to both the eventual enforcement
of rule 6 in getopt(3c), also enforced in the version that I
posted some time ago, and the change in behavior of getopt(1);
a DIFFERENT NAME such as getopts(1) should have been chosen, to
avoid breaking existing shell scripts that use the old getopt(1).

peter@graffiti.UUCP (Peter da Silva) (10/24/85)

> The source code for the "real" getopt.c is available at no charge
> from the Unix (TM) System Toolchest.  Dial (201) 522-6900 from your
> 1200 baud modem and log in as "guest" for further details.

Is that no charge, or no charge after you've paid the initial hundred-odd-
dollar licensing fee to use the toolchest?
-- 
Name: Peter da Silva
Graphic: `-_-'
UUCP: ...!shell!{graffiti,baylor}!peter
IAEF: ...!kitty!baylor!peter

peter@graffiti.UUCP (Peter da Silva) (10/24/85)

> Incidentally, I strongly object to both the eventual enforcement
> of rule 6 in getopt(3c),

What is rule 6?
-- 
Name: Peter da Silva
Graphic: `-_-'
UUCP: ...!shell!{graffiti,baylor}!peter
IAEF: ...!kitty!baylor!peter

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (10/26/85)

> What is rule 6?

That's the one that prohibits options like
	$ cc -ofoo foo.c
and requires that there be a space:
	$ cc -o foo foo.c

gnu@l5.uucp (John Gilmore) (10/26/85)

In article <811@wcom.UUCP>, frodo@wcom.UUCP (Jim Scardelis) writes:
> 	The AT&T version of getopt(3c) is available for free, with free
> sub-licensing from the AT&T Toolchest [(201) 522-6900, login: guest]. 

This is misleading.  AT&T will sell it for free to anyone who is
signed up with the Toolchest, but you either have to pay $100 to sign
up, or own a source license ($43K).  You also have to wait for them
to mail you a contract then you sign it and mail it back then they
eventually flip a bit that lets you "buy" things.*

Will someone who has already gone thru this please post the source
to the net.sources?  The sublicense fee is $0 so you should be able to
"sell" it to all of us and AT&T doesn't care.  Right?

(I've seen Henry Spencer's version and it seems to work just fine.
Is there any reason why I'd want the AT&T version?)

Flame about Toolchest:  They seem to be afraid of Unix experts; they
stick you in a menu system and won't let you out.  I wanted to see the
price ranges, but there's no way to get a simple list of tool names and
prices, unless you ask about each tool individually.  Thanks AT&T.

* I think this is kind of funny, from the company that transacts
ALL its business over the phone.  They never made me sign a contract
for phone service or long distance...I just call up, tell them I'm me
(or anybody else), and order what I want.  It shows up on my phone bill.
Why can't they do that for the Toolbox?

mike@whuxl.UUCP (BALDWIN) (10/26/85)

> > Incidentally, I strongly object to both the eventual enforcement
> > of rule 6 in getopt(3c),
> 
> What is rule 6?

Hello Peter, did you read your followups in net.sources.bugs?  AGAIN,
here is Rule 6 of the Proposed Syntax Standard for UNIX System Commands:

	The first option-argument following an option must
	be preceded by white space.

Now, is this clear?  This means that if you have -o with an argument, say
foo, you have to have a space between -o and foo.  Also, Rule 5 says that
options with no arguments can be grouped together, implying that options
*with* arguments have to stand alone.  Now, using this Proposed Syntax,
you'd have to say "sort -bf -t x" instead of "sort -bftx".

But now READ CAREFULLY:  THIS IS THE PROPOSED SYNTAX, NOT THE CURRENT
BEHAVIOUR OF GETOPT(3C).  Getopt(3C) does *NOT* currently enforce Rule 6
or the strict Rule 5, so "sort -bftx" works with getopt(3C).  It has been
threatened that getopt will enforce these eventually, but I strongly
disagree with that action.  It should be left the way it is, but the
documentation needs to be cleaned up (optind and opterr are documented
wrong, and optopt isn't documented [why is it an int and not a char?]).
-- 
						Michael Baldwin
						{at&t}!whuxl!mike

ado@elsie.UUCP (Arthur David Olson) (03/06/86)

> . . .They proposed altering the usage
> of getopt(1) from the current
> 	set -- `getopt ops $*`
> to
> 	eval set -- "`getopt ops "$@"`"

Do note that
	set -- whatever
is considered an error by the "sh" that comes with 4.[123]bsd.  When writing
shell scripts, you can make life easier for bsders by doing a
	set -$- whatever
which is acceptable to both bsd and System V.
--
UNIX is an AT&T Bell Laboratories trademark.
--
	UUCP: ..decvax!seismo!elsie!ado    ARPA: elsie!ado@seismo.ARPA
	DEC, VAX and Elsie are Digital Equipment and Borden trademarks

msc_wers@jhunix.UUCP (Edward R Scheinerman) (08/22/86)

I recently wrote a C program which calls getopt() under Unix System V.
I sent the code to a friend who cannot compile it because he has BSD 4.2.
Is the source code for getopt() public domain? If so where can I get a
hold of a copy? Any other suggestions on how to fix this up? Thanks!

-Ed Scheinerman
 msc_wers@jhunix	Department of Mathematical Sciences
 301-338-7210		The Johns Hopkins University
			Baltimore, Maryland 21218 USA