🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1014

Re: Yet Another bourne shell query

#1014
From: Jeff Beadles
Date: Fri, 31 Aug 1990 14:59
29 lines
1384 bytes
jc@minya.UUCP (John Chambers) writes:
>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?

Well, from the test(1) man page...

     -t [ fildes ]
               True if the open file whose file descriptor number
               is fildes (1 by default) is associated with a
               terminal device.

This, you can tell if a file descriptor is attached to a terminal.  (It will
fail for a pipe or redirection)

Thus, something like this might be what you are looking for:

if [ -t 0 ] ; then
	exec </dev/null
fi

Best of luck,

	-Jeff
-- 
Jeff Beadles				  jeff@quark.WV.TEK.COM 
UTek Network Engineering, Tektronix Inc.  +1 503 685 2568
			SPEEA - Just say no.
Technical Details
Message-ID: <8478@orca.wv.tek.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!pacbell!pacbell.com!mips!zaphod.mps.ohio-state.edu!wuarchive!mit-eddie!uw-beaver!zephyr.ens.tek.com!orca.wv.tek.com!quark!jeff
References: <437@minya.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!pacbell!pacbell.com!mips!zaphod.mps.ohio-state.edu!wuarchive!mit-eddie!uw-beaver!zephyr.ens.tek.com!orca.wv.tek.com!quark!jeff
From: jeff@quark.WV.TEK.COM (Jeff Beadles)
Newsgroups: comp.unix.shell
Subject: Re: Yet Another bourne shell query
Message-ID: <8478@orca.wv.tek.com>
Date: 31 Aug 90 14:59:35 GMT
References: <437@minya.UUCP>
Sender: news@orca.wv.tek.com
Reply-To: jeff@quark.WV.TEK.COM (Jeff Beadles)
Organization: Tektronix, Inc., Wilsonville, OR
Lines: 29