Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re: How to tell if you're in a pipe... Keywords: pipe tty(1) sh(1) isatty(4) Message-ID: <2825@solo3.cs.vu.nl> Date: 3 Jul 89 19:48:57 GMT References: <1798@lgnp1.LS.COM> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 22 rbarrell@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@cs.vu.nl, mcvax!botter!maart