[net.sources.bugs] Possible bug in less

qtest@whuxl.UUCP (QTEST) (11/07/85)

I think I've found a bug in less.

I think it stems from the difference in the way the following two commands
are called, One with a pipe and one without, e.g.

	1) 	cat filename | less	
	2)	less filename

Both of the above commands will list the first page (assuming 'filename'
is longer than one page) and give the ":" prompt. If at this prompt
the command "!sh" is entered, command type 1) will wait for a few seconds
and then return "!done (press RETURN)". Command type 2) will correctly
spawn the shell and repond with the usual PS1 prompt.

My question is; why does the first command, i.e. the one using the pipe
NOT spawn a shell, but simply return to less?
Are the above differences a result of the pipe?
By the way my version of less was compiled on SVR2 if that helps.

			qtest  {ihnp4}whuxl!qtest

gnu@l5.uucp (John Gilmore) (11/13/85)

In article <781@whuxl.UUCP>, qtest@whuxl.UUCP (QTEST) writes:
> I think I've found a bug in less. 
> 	1) 	cat filename | less	
> 	2)	less filename
> If the command "!sh" is entered, command type 1) will wait for a few seconds
> and then return "!done (press RETURN)".

The problem is that "less" just forks a shell, passing standard
input, output, and error to it (and any other files it has open).
If the standard input of "less" is the output of "cat", this (or
whatever part of it "less" hasn't read) will be the input to the shell.

I have a fix for this but I didn't keep separate diffs.  I've been
working on "less" and will send all my changes to mod.sources someday.
I don't think the fix is really urgent.  If you have to, just use the
"!sh </dev/tty" command instead.