Odd vi behaviour inside a shell script.

Jonathan I. Kamens jik at athena.mit.edu
Wed May 9 16:00:25 AEST 1990


In article <20829 at boulder.Colorado.EDU>, meadb at boulder.Colorado.EDU
(MEAD BENNETT ROSS) writes:
|> Alright, I don't know what characters are echoed to the screen by ioctl,
|> but it shouldn't be hard to find out.  Write a C program that echos
|> these characters to stdout.  Not too bad, but it will require a
little research,
|> and a little C knowledge.  Then put this C program in your shell
script.  Not
|> trivial, but there are ways to get around this problem, but it will take
|> longer than just using ed.  (as suggested by Dan.)  But it looks like it's 
|> possible to do this.

  It is erroneous to assume that an ioctl works by echoing characters to
the screen.  In fact, I very much doubt that the ioctl to put the
terminal into raw mode echoes anything to the screen.

  Therefore, what you would have to do is to write a C program to do the
ioctl(s) vi does when it starts up, not a C program to echo characters
to stdout.

  However, it is likely that vi doesn't only do ioctl() calls when it
starts up -- it also probably does them while it's working.  The
ioctl()'s it does while it's working will probably fail, and it will
lose.  Hence I think the suggestion to use ex, rather than vi, was
probably a better one.

  Note that Dan did not suggest the use of ed.  He suggested the use of
ex, which is very different from ed.  Ed is a line-based editor, while
ex is display-based (like vi).  In fact, ex and vi run the same code,
which is why the output of vi and ex are similar.

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list