Question about GETOPT(3)
Farooq Butt
fmbutt at cloud9.Stratus.COM
Tue Oct 31 10:45:11 AEST 1989
Dear Unix Wizards/question-answerers:
here is code fragment from the 4.3 BSD Tahoe distribution of UNIX.
It is from a program called "uux" from the uucp suite.
Uux is supposed to take '-' as an argument where saying:
"uux -"
means "take input from stdin." But to my shock and horror,
when I compiled uux and gave it the "-" argument it refused to
recognize it and did not take input from stdin. Since "uux -p"
here means the exact same thing as "uux -" I satisfied myself
to use it without reasoning why. However lately, I've had the chance
to look at the code again and it seems that what the guys who wrote
4.3 Tahoe UUCP must not have been using the same "getopt" routine I
am on a Sun. The code fragment in question is here:
while ((c = getopt(argc, argv, "-prclCg:x:nzLa:")) != EOF)
switch (c) {
case '-':
/* FALLTHROUGH */
case 'p':
pipein = 1;
break;
case 'r':
startjob = 0;
break;
case 'c':
Copy = 0;
Linkit = 0;
break;
...... and more code unrelated to getopt......
Questions:
. Should that code above work in principle given a "standard"
getopt routine ?
. Does getopt have its roots in BSD or SysV ?
. Is the SunOS getopt (the one I am using) buggy and simply
not dealing with a lone "-" ?
. How would one get getopt to deal with single dash options ?
(I want to say cat FOO | uux - -r 'jkfghkjhgfdkjh' )
^
|
This '-' is the arg getopt
does not like
Thanks for the help !!!
--
NOTHING in the above article has the slightest relationship to reality.
If any reality correspondences are found, please notify me IMMEDIATELY.
Any threats, abuse or stupidity of any kind are purely UNINTENTIONAL.
My employer does not know that I exist and is not responsible for anything.
More information about the Comp.unix.questions
mailing list