From: utzoo!decvax!harpo!floyd!cmcl2!philabs!crh Newsgroups: net.sources Title: "redo" stuff Article-I.D.: philabs.9812 Posted: Fri Sep 3 15:59:25 1982 Received: Sun Sep 5 03:06:04 1982 Here is the "redo" stuff I promised in net.unix-wizards. First the alias: alias ! '/usr/local/redo \!* ~/.cmd ~/.cmd1 ; source ~/.cmd1 ' Here is redo.c. I could have used a script, but didnt. #include/* redo -- outputs a command file (last arg )used to edit and re-ex a command. Next to last arg is dest file of the command. First arg is the history ref . To use: alias ! 'redo \!* ~/cmd ~/cmd1 ; source ~/cmd1 ' ! 25 to edit & re-execute !25 ! ! or ! to edit & re-execute !! ! v to edit & re-execute !v ,etc. */ main(argc, argv) int argc; char *argv[]; { FILE *fp; fp=fopen(argv[argc-1],"w"); fputs("echo \"!",fp); if ((argc<4)|| (strcmp(argv[1],"!")==0)) fputs("-2",fp); else fputs(argv[1],fp); fputs(":q\" >! ",fp); fputs(argv[argc-2],fp); putc('\n',fp); fputs("ex +open ",fp); fputs(argv[argc-2],fp); putc('\n',fp); fputs ("/usr/local/typein2 < ",fp); fputs (argv[argc-2],fp); putc('\n',fp); fclose(fp); exit(0); } Here is typein2.c, a modified version of typein.c, which takes its std input (assumed to be small (<=256 chars) ) and places it in the tty INPUT : #include #include main(argc, argv) int argc; char **argv; { register char *cp; struct sgttyb stb, stb2; int pendin = LPENDIN; int c,i,j; char buff[2]; char buff2[256]; i=0; while ((c=getchar()) != EOF) { buff2[i++]=c; } ioctl(2, TIOCGETP, &stb); stb2 = stb; stb.sg_flags &= ~ECHO; ioctl(2, TIOCSETN, &stb); for (j=0; j