1 9aa1c92f 2005-01-04 devnull #include "mk.h"
3 9aa1c92f 2005-01-04 devnull static Shell *shells[] = {
8 9aa1c92f 2005-01-04 devnull Shell *shellt;
9 9aa1c92f 2005-01-04 devnull Word *shellcmd;
11 9aa1c92f 2005-01-04 devnull typedef struct Shellstack Shellstack;
12 9aa1c92f 2005-01-04 devnull struct Shellstack
14 9aa1c92f 2005-01-04 devnull Shell *t;
16 9aa1c92f 2005-01-04 devnull Shellstack *next;
19 9aa1c92f 2005-01-04 devnull Shellstack *shellstack;
22 9aa1c92f 2005-01-04 devnull setshell(Word *w)
26 9aa1c92f 2005-01-04 devnull if(w->s == nil)
27 9aa1c92f 2005-01-04 devnull return "shell name not found on line";
29 9aa1c92f 2005-01-04 devnull for(i=0; i<nelem(shells); i++)
30 9aa1c92f 2005-01-04 devnull if(shells[i]->matchname(w->s))
32 9aa1c92f 2005-01-04 devnull if(i == nelem(shells))
33 9aa1c92f 2005-01-04 devnull return "cannot determine shell type";
34 9aa1c92f 2005-01-04 devnull shellt = shells[i];
35 9aa1c92f 2005-01-04 devnull shellcmd = w;
36 9aa1c92f 2005-01-04 devnull return nil;
40 9aa1c92f 2005-01-04 devnull initshell(void)
42 9aa1c92f 2005-01-04 devnull shellcmd = stow(shells[0]->name);
43 9aa1c92f 2005-01-04 devnull shellt = shells[0];
47 9aa1c92f 2005-01-04 devnull pushshell(void)
49 9aa1c92f 2005-01-04 devnull Shellstack *s;
51 9aa1c92f 2005-01-04 devnull /* save */
52 9aa1c92f 2005-01-04 devnull s = Malloc(sizeof *s);
53 9aa1c92f 2005-01-04 devnull s->t = shellt;
54 9aa1c92f 2005-01-04 devnull s->w = shellcmd;
55 9aa1c92f 2005-01-04 devnull s->next = shellstack;
56 9aa1c92f 2005-01-04 devnull shellstack = s;
58 9aa1c92f 2005-01-04 devnull initshell(); /* reset to defaults */
62 9aa1c92f 2005-01-04 devnull popshell(void)
64 9aa1c92f 2005-01-04 devnull Shellstack *s;
66 9aa1c92f 2005-01-04 devnull if(shellstack == nil){
67 9aa1c92f 2005-01-04 devnull fprint(2, "internal shellstack error\n");
71 9aa1c92f 2005-01-04 devnull s = shellstack;
72 9aa1c92f 2005-01-04 devnull shellstack = s->next;
73 9aa1c92f 2005-01-04 devnull shellt = s->t;
74 9aa1c92f 2005-01-04 devnull shellcmd = s->w;