🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1012

Yet Another bourne shell query

#1012
From: John Chambers
Date: Fri, 31 Aug 1990 02:06
27 lines
1650 bytes
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)
Technical Details
Message-ID: <437@minya.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!mit-eddie!minya!jc

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!mit-eddie!minya!jc
From: jc@minya.UUCP (John Chambers)
Newsgroups: comp.unix.shell
Subject: Yet Another bourne shell query
Message-ID: <437@minya.UUCP>
Date: 31 Aug 90 02:06:01 GMT
Lines: 27