How to tell if you're in a pipe...

Maarten Litmaath maart at cs.vu.nl
Tue Jul 4 05:48:57 AEST 1989


rbarrell at lgnp1.LS.COM (Robert Barrell) writes:
\
\     if [ `tty -s;echo $?` = 0 ]
\     then
\         echo "terminal"
\     else
\         echo "pipe"
\     fi

What an `interesting' way to accomplish the following:

	if tty -s
	then
		echo terminal
	else
		echo pipe
	fi
or even
	tty -s && echo terminal || echo pipe
-- 
"I HATE arbitrary limits, especially when |Maarten Litmaath @ VU Amsterdam:
   they're small."  (Stephen Savitzky)    |maart at cs.vu.nl, mcvax!botter!maart



More information about the Comp.unix.questions mailing list