VI & spell

Maarten Litmaath maart at cs.vu.nl
Tue Nov 14 08:57:47 AEST 1989


In article <740 at uc.msc.umn.edu> glex at uf.UUCP (Jeffrey Gleixner) writes:
\I finally have gotten so sick of typo's that I want to run spell while in
\vi, without exiting or suspending, the file.   So I wrote a small script (sp).
\It takes the input from vi (:1,$!sp) and redirects it to a file, I run
                             ^^^^^^^
This command will overwrite the buffer with the output from sp.
The following command will just feed the buffer to sp:

	:w !sp

Notice the space between the `w' and the `!'.

\spell on the file, pulling up a window (Sun) displaying the output from spell.
\The window waits for a <CR> and then exits.  Well that works just fine EXCEPT 
\that I can't continue with vi until I exit the window, probably waiting for 
\the !sp to finish.

Indeed.  Try something like this for sp (without the indentation!):

	#!/bin/sh

	cat > /tmp/sp.$$
	trap '' 2 18 21 22 	# trap SIGINT, SIGTSTP, SIGTTIN and SIGTTOU
	(
		# do funny stuff here
	) &	# maybe some redirections are appropriate

sp exits while its child will continue processing in the background.
If you don't trap the stop signals, something `funny' happens when you
stop vi (^Z) while the background job is still running, so that it would
be stopped too, implicitly: (relevant BSD kernel code)

	case SIGTSTP:
	case SIGTTIN:
	case SIGTTOU:
		/*
		 * Children of init aren't allowed to stop
		 * on signals from the keyboard.
		 */
		if (p->p_pptr == &proc[1]) {
			psignal(p, SIGKILL);
			continue;
		}

The stop signal is changed to a kill signal!
BTW, how about the following, Mr. Bourne?!

	trap '' SIGINT SIGTSTP SIGTTIN SIGTTOU
or
	trap '' INT TSTP TTIN TTOU
-- 
"Richard Sexton is actually an AI program (or Construct, if you will) running
on some AT&T (R) 3B" (Richard Brosseau) | maart at cs.vu.nl, mcsun!botter!maart



More information about the Comp.unix.questions mailing list