tabs in vi

Leslie Mikesell les at chinet.chi.il.us
Mon Sep 4 13:58:24 AEST 1989


In article <720011 at hpcljws.HP.COM> jws at hpcljws.HP.COM (John Stafford) writes:
>BEWARE:  Most versions of vi I've seen can trash your file if you pipe
>too much though a filter program (like expand).  I have had files
>trashed doing exactly 1G!Gexpand.  You get a block of lines replaced
>with blank lines and the original lines get moved someplace else and
>rotated to various degrees.

>I believe a race condition is involved.  While the failure is rare and
>correlates positively with increasing file size, I have never known
>exactly what triggers it (I'm sure somebody reading this knows and can
>enlighten us).

Vi must be using the text buffer to read the output from the process at
the same time it is sending the original text to the process.  This seems
kind of silly since a copy is made so you can "undo" the command.  If
you notice the problem soon enough, "undo" will fix it, but I've had
enough trouble that if the file is more than a few pages I always write
the file out, delete the buffer, and read the process input back in:
:w<return>:1,$d<return>:0r !cmd %<return>
doesn't take much longer, doesn't screw up, and it gives you more of a
chance to recover the original copy if you decide the filter did not
do the desired operation.

Les Mikesell



More information about the Comp.unix.questions mailing list