Detecting Pipe Using Bourne Shell
DAVID NEWALL
ccdn at levels.sait.edu.au
Tue Apr 11 04:29:09 AEST 1989
In article <18992 at adm.BRL.MIL>, ifenn%ee.surrey.ac.uk at nss.cs.ucl.ac.uk (Ian Fenn) writes:
> [ how can you tell if a program's input comes from a pipe? ]
I recommend testing to see if stdin is a terminal. I believe the following
will do what you want:
if [ -t 0 -a $# -eq 0 ]; then
echo menu
...
else
...
fi
(I assume you only want a menu when the program is run from a terminal)
David Newall Phone: +61 8 343 3160
Unix Systems Programmer Fax: +61 8 349 6939
Academic Computing Service E-mail: ccdn at levels.sait.oz.au
SA Institute of Technology Post: The Levels, South Australia, 5095
More information about the Comp.unix.wizards
mailing list