[comp.unix.wizards] BSD script program.

franco@MIKEY.BBN.COM (04/28/87)

	Before the existence of psuedo tty's (pty's), in particular,
BSD4.1 for VAX and BSD2.8 and BSD2.9 for PDP-11(I don't know of other
versions of UNIX for the PDPs), the script program used pipes to
capture typed in commands and the commands output into a file called
typescript.

	PROBLEM:  The program worked fine this way except that
if one tried to 'more' a file it wouldn't work(a bug that I am not
sure was ever fixed, also trying to 'vi' a file bombed)..  What I
mean by bombed or failed to work is that after hitting the <CR> you
would get nothing back, no prompt, no text.  I found that if you
hit the EOF key, the file you were more'ing would scroll by your screen
as if you cat'd it.  It also turns out that 'more' thought you were
trying to view more than one file, the first file being a NULL file
with a NULL name(the same for vi, strange!).

	QUESTION:  Has the script program ever been fixed to work
correctly with pipes and if so, can I get a context diff of the version
that works with the version released for BSD2.9 or BSD4.1(please!!!)???
The version I have is @(#)script.c 4.1 (Berkeley) 10/1/80.  Although
it would be *nice* to get the complete program!

	If anyone out there has solved this problem on their own, I
would greatly appreciate any help you can give.


Frank "franco" Lonigro
CSNET	franco%bbn.com@relay.cs.net
UUCP	franco%bbn.uucp@harvard.harvard.edu

chris@mimsy.UUCP (Chris Torek) (04/28/87)

In article <7141@brl-adm.ARPA> franco@MIKEY.BBN.COM (Frank A. Lonigro) writes:
>.. the script program [once] used pipes to capture typed in commands
>and the commands output into a file called typescript. ... if one tried
>to 'more' a file it wouldn't work (a bug that I am not sure was ever
>fixed, also trying to 'vi' a file bombed). ... Has the script program
>ever been fixed to work correctly with pipes ... ?

Script is not at fault, and there is nothing there that can be
fixed.  The problem is with the whole notion of `interactivity'.
More, vi, and other programs---indeed, all programs that use
stdio---assume that if the standard input and output are `typewriters'
(if isatty()) is true), the program is interactive.  If not, the
program is not being used interactively and need not behave interactively.

This is fine for

	grep ... | sed ... | awk ...

but fails miserably for script.  Short of altering all programs
that misbehave, there is nothing that can be done.  Ptys work around
this; but the more proper solution is to redefine `interactive' and
rewrite the system.  But I am not going to attempt it.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	seismo!mimsy!chris	ARPA/CSNet:	chris@mimsy.umd.eduR

rbj@icst-cmr.arpa (04/30/87)

   >ever been fixed to work correctly with pipes ... ?

   Script is not at fault, and there is nothing there that can be
   fixed.  The problem is with the whole notion of `interactivity'.
   More, vi, and other programs---indeed, all programs that use
   stdio---assume that if the standard input and output are `typewriters'
   (if isatty()) is true), the program is interactive.  If not, the
   program is not being used interactively and need not behave interactively.

Or more properly, isatty(0) or isatty(1). One way of getting around this
is to use a flag as `sh' does (-i) to force `interactivity'.

Nor is it clear which of stdin/stdout implys interactiveness. In `sh's
case, the test leans toward stdin, while with more, it clearly lies
with stdout, which is where `more' reads its commands from.
I imagine there is a reason why `stty' refers to its stdout as well.

   This is fine for

	   grep ... | sed ... | awk ...

   but fails miserably for script.  Short of altering all programs that
   misbehave, there is nothing that can be done.  Ptys work around this;

Pty's also solve the ioctl problem as well.  In some cases, useful
information could be had by looking at stderr.

   but the more proper solution is to redefine `interactive' and
   rewrite the system.  But I am not going to attempt it.

Sounds like a job for Interactive Systems :-)

   In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
   UUCP:	seismo!mimsy!chris	ARPA/CSNet:	chris@mimsy.umd.edu

	(Root Boy) Jim "Just Say Yes" Cottrell	<rbj@icst-cmr.arpa>
	I hope I bought the right relish...zzzzzzzzz..."