Yet Another bourne shell query
John Chambers
jc at minya.UUCP
Fri Aug 31 12:06:01 AEST 1990
Hey, wow!, a special group for all my dumb shell questions! And I just
happen to have one to ask...
Recently, I've had the fun of modifying programs so they can be started
by init and/or inetd, and still work. These daemons, unlike shells,
have a way of starting programs with very little initialization. On
some of my recent portability tests, I have even come across one Unix
system whose init starts things with an empty environ vector (i.e.,
environ[0] == (char *)0), and with NO open files. Yes, you read that
right; files 0, 1 and 2 are not open. It does at least make argv[0]
contain a pointer to the program's name, and argc is correct, so I
guess I really shouldn't complain.
But this causes interesting problems when the "program" is a shell
script. In C, I know how to call fstat() and test the result for
zero. In Bourne Shell, I don't know how to do the equivalent. I
basically want to write something like:
if [ <file 0 is open> ];then exec</dev/null;fi
but I don't know what to put between the [ and the ]. Any ideas?
Is it possible? Or should I just rewrite the scripts in C?
--
Zippy-Says: Imagine ... a world without clothing folds, chiaroscuro, or marital difficulties ...
Home: 1-617-484-6393 Work: 1-508-952-3274
Uucp: ...!{harvard.edu,ima.com,eddie.mit.edu,ora.com}!minya!jc (John Chambers)
Uucp-map: minya adelie(DEAD)
More information about the Comp.unix.shell
mailing list