[comp.unix.questions] Odd vi response when input redirected

ray@saturn.ucsc.edu (Ray Swartz) (08/07/89)

On System V machines, the command

	cat | vi

works fine.  [On BSD systems, vi gives an error message and won't work properly]
The benefit of redirecting the input of vi is that you can put your own
process in place of cat and implement a "hot key" function for vi.  On my
system, the hot key (a ctrl-A) displays a vi help menu for novice users.

The hot key works great.  The problem is that now the shell escape doesn't
work properly.  When I enter :!cmd, the command appears to be run, but the
output doesn't go the the terminal.  For example, :!ls produces no output.

This seems like odd behaviour since only the input of vi has been redirected.

Where does the output of the !cmds go?  BTW, I tried !cmd > /dev/tty
but that didn't do anything either.

Thanks in advance.

Ray Swartz

I've noticed an odd vi feature and don't know why it reacts the way it does.

ray@saturn.ucsc.edu (Ray Swartz) (08/08/89)

In article <8649@saturn.ucsc.edu> I wrote:
>On System V machines, the command
>
>	cat | vi
>
>works fine.  The problem is that now the shell escape doesn't
>work properly.  When I enter :!cmd, the command appears to be run, but the
>output doesn't go the the terminal.  

I discovered the problem to be a recently implemented Korn shell.  For
some reason, when the pipeline is started in the Korn shell (or the SHELL
variable is set to /bin/ksh), the :!cmd doesn't work.  It works find
if you don't use the pipeline.

BTW, don't assume that you can go from Bourne shell to the Korn shell
without any problems.  Bourne shell scripts will stop working properly
and the reference books are none too good.  This one ate 4 hours.

Ray Swartz
ray@saturn.ucsc.edu
{sun,uunet}!uworld!ans2unix

maart@cs.vu.nl (Maarten Litmaath) (08/24/89)

ray@saturn.ucsc.edu (Ray Swartz) writes:
\...
\The benefit of redirecting the input of vi is that you can put your own
\process in place of cat and implement a "hot key" function for vi.  On my
\system, the hot key (a ctrl-A) displays a vi help menu for novice users.

Easy. In /etc/profile (or .profile, .login, etc.) simply put:

	EXINIT='map ^A :!/usr/lib/vi_help^M'
	export EXINIT

or something alike.  No need to redirect stdin.
-- 
"rot H - dD/dt = J, div D = rho, div B = 0, |Maarten Litmaath @ VU Amsterdam:
  rot E + dB/dt = 0" and there was light.   |maart@cs.vu.nl, mcvax!botter!maart