Multiline aliases in csh ?

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Wed Oct 24 07:22:32 AEST 1990


In article <10084 at jpl-devvax.JPL.NASA.GOV> lwall at jpl-devvax.JPL.NASA.GOV (Larry Wall) writes:
> No, but you can often get the same effect using a program that forces
> multiple commands back into your input:
> alias patchit forceme "'"'foreach file (*.pat)'"'"\; \
> forceme "'"'patch <$file'"'"\; \
> forceme 'end'

I assume that ``forceme'' uses TIOCSTI to simulate terminal input. For
readers without it, enclosed is tiocsti, which does the same job.

> Won't work in a script, of course, but if you're just interested in being
> a lazy typist...

Right. Btw, why don't you use \' rather than "'"? Might not work in
awk, of course, but if you're just interested in being a lazy typist...
Actually, it'd be a lot clearer to just double-quote your entire alias.

---Dan

/* Public domain. */
#include <sys/ioctl.h>

main(argc,argv)
int argc;
char *argv[];
{
 int j;
 char *s;

 if (ioctl(3,TIOCGPGRP,(char *) &j) == -1)
   (void) dup2(0,3);

 for (j = 1;j < argc;j++)
  {
   for (s = argv[j];*s;s++)
     (void) ioctl(3,TIOCSTI,s);
   if (j < argc - 1)
     (void) ioctl(3,TIOCSTI," ");
  }
}

TH tiocsti 1
SH NAME
tiocsti \- simulate terminal input
SH SYNOPSIS
B tiocsti
[
I arg
] ...
SH DESCRIPTION
I tiocsti
``types'' each of its arguments on the
current terminal, separated by spaces,
as if you had typed them.
SH "SEE ALSO"
tty(4)



More information about the Comp.unix.shell mailing list