correct isatty usage

Lawrence V. Cipriani lvc at cbnews.ATT.COM
Fri Feb 24 18:02:36 AEST 1989


In article <1161 at tikal.Teltone.COM>, dave at tikal.Teltone.COM (news) writes:
+ Now my question is, how would you do this in a script?  Either C or Bourne.
+ In C shell, I have this code, but it doesn't appear to work.
+ 
+ if ({`test -t 0`}) then
+     echo -n "==> "
+ else
+     echo -n "--> "
+ endif

What you want is (Bourne shell or Korn shell):

	if [ -t 0 ]
	then
		echo stdin is a terminal
	else
		echo stdin is not a terminal
	fi
-- 
Larry Cipriani, att!cbnews!lvc or lvc at cbnews.att.com



More information about the Comp.unix.questions mailing list