From: utzoo!decvax!cca!Michael.Young@CMU-CS-A@sri-unix Newsgroups: net.unix-wizards Title: Re: useful view extension Article-I.D.: sri-unix.4253 Posted: Sat Nov 20 01:58:25 1982 Received: Sun Nov 21 02:21:41 1982 From: Michael Wayne Young Date: 16 November 1982 1853-EST (Tuesday) "don't extend vi, do it yourself with a shell script:" -- that's sick. I cannot believe that anyone with any talent at using a Unix system would write a shell script for something that they (or anyone else they give it to) will use often. Parsing arguments, handling interrupts, etc. are best done in a program, not a shell script. I draw an analogy to the difference between a compiler or an interpreter -- you don't run your BASIC interpreter on anything that's gonna get used much; you don't compile things (well, you shouldn't have to, but I usually do anyway) that you'll just run once. I think "vi" is large and complex, but it is clearly the place to put the additions. How do you suspect "vi" reads in its input file into its buffer in the first place? Would it be too much trouble to alter the mechanism which does that to accept standard input rather than opening a file? I think not. Another point you bring up is the use of /tmp files. Ugh again. What you end up doing is wasting more space in /tmp for a file that you will throw away. In fact, I also find that people use /tmp (and /usr/tmp) an awful lot when they can easily avoid it -- it's a matter of convenience (until you run out of space, or other disaster strikes). I'd in fact be in favour of allowing you to specify an "unnamed" file to be created, for just these types of appplications; for example, rather than doing something like: f = creat ("/tmp/foo", 0666); /* Make my file, with name */ f2 = open ("/tmp/foo", 0); /* Get a readable fd too */ unlink ("/tmp/foo"); /* Throw away the filename */ ... you'd instead do something like f = creat_unnamed ("/tmp/foo"); [With 4.2BSD, this'd just be another mode bit, not a whole new call -- save the flaming here.] Why the filename? Just so the kernel doesn't make the decision where to put the file (which filesystem); also note that no mode is necessary if you don't want a filename to ever appear in a directory. I may sound a bit too efficiency-oriented, but I think that keeping in mind what resources you're using is important. Abusing "sh" and "/tmp/" are just personal dislikes. Then of course is the multi-pass nature of your approach: one pass to copy to /tmp/, one to read into "vi", and if you wanted to alter it, you'd also make another to copy from /tmp/ to standard output. Yuch again. Michael