mcvoy@uwvax.UUCP (04/19/87)
Hi there. Here's a hack that makes finger(1) smart about your internet mail aliases. It looks in ~/.fingerc (which is usually a link to ~/.mailrc) for lines of the form alias foo foo@xerox.com and if you said finger foo you will see (foo: foo@xerox.com) <== my stuff [foo@xexox.com] <== standard finger output The only thin it needs are index(3) (aka strchr) and $HOME in your environment. Oh yeah, FINGER is defined to the real finger (/usr/ucb/finger). For BSD systems this should slide right in; for others, well.... No man page, unless someone asks... Options: -I (ignore) ignores aliases. Enjoy, -larry # ----- cut here ---- # This is a shell archive. Remove anything before this line, then # unpack it by saving it in a file and typing "sh file". (Files # unpacked will be owned by you and have default permissions.) # # This archive contains: # finger.c echo x - finger.c cat > "finger.c" << '//E*O*F finger.c//' static char* id = "@(#)finger.c - main, strsav; mcvoy@rsch.wisc.edu"; /* finger - provide front end for finger that loads aliases. * * Look in ~/.fingerc for aliases. You could link this to .mailrc. * * An alias is the regular expression: * * ^alias[ <tab>]+name[ <tab>]+full_name * * and finger name gets translated to finger fullname. * Exception: any fullname that contains a "!" is ignored (can't do uucp, * only internet). * * Options: -I ignores the dotfiles; a good way to finger a local john instead * of an aliased john. */ # include <stdio.h> # include <ctype.h> # define FINGER "/usr/ucb/finger" main(ac, av, ev) char** av; char** ev; { char fingerc[255]; char buf[500]; register i; FILE* f = (FILE*)-1; char* strsav(); sprintf(fingerc, "%s/.fingerc", getenv("HOME")); if (!strcmp(av[1], "-I") || !(f = fopen(fingerc, "r"))) { if (f == (FILE*)-1) { /* shift av down. */ register i; for (i=1; i<ac; i++) av[i] = av[i+1]; } execve(FINGER, av, ev); perror(FINGER); } /* stupid alg: scan the file for each av, but there's usually only one. */ for (i=1; i<ac; i++) { rewind(f); while (fgets(buf, sizeof(buf), f)) { register char* s; register char* t; register len = strlen(av[i]); if (strncmp(buf, "alias", 5)) continue; for (s=buf + 5; *s && isspace(*s); s++) ; if (!strncmp(s, av[i], len) && isspace(*(s + len))) { s += len; for ( ; *s && isspace(*s); s++) ; for (t=s; *t && !isspace(*t); t++) ; *t = NULL; if (!index(s, '!')) { fprintf(stderr, "(%s: %s)\n", av[i], s); av[i] = strsav(s); break; /* while, get next i */ } } } } execve(FINGER, av, ev); perror(FINGER); } char* strsav(s) register char* s; { char* malloc(); char* strcpy(); register char* t = malloc(strlen(s) + 1); return strcpy(t, s); } //E*O*F finger.c// echo Possible errors detected by \'wc\' [hopefully none]: temp=/tmp/shar$$ trap "rm -f $temp; exit" 0 1 2 3 15 cat > $temp <<\!!! 85 290 1956 finger.c !!! wc finger.c | sed 's=[^ ]*/==' | diff -b $temp - exit 0 -- Larry McVoy mcvoy@rsch.wisc.edu or uwvax!mcvoy "It's a joke, son! I say, I say, a Joke!!" --Foghorn Leghorn
ken@rochester.UUCP (04/19/87)
If you run MH you can define this alias: alias f finger '`ali \!*`' Slows you down a little, that's all. Ken