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];
44 c8b6342d 2005-01-13 devnull setvar("MKSHELL", shellcmd);
48 9aa1c92f 2005-01-04 devnull pushshell(void)
50 9aa1c92f 2005-01-04 devnull Shellstack *s;
52 9aa1c92f 2005-01-04 devnull /* save */
53 9aa1c92f 2005-01-04 devnull s = Malloc(sizeof *s);
54 9aa1c92f 2005-01-04 devnull s->t = shellt;
55 9aa1c92f 2005-01-04 devnull s->w = shellcmd;
56 9aa1c92f 2005-01-04 devnull s->next = shellstack;
57 9aa1c92f 2005-01-04 devnull shellstack = s;
59 9aa1c92f 2005-01-04 devnull initshell(); /* reset to defaults */
63 9aa1c92f 2005-01-04 devnull popshell(void)
65 9aa1c92f 2005-01-04 devnull Shellstack *s;
67 9aa1c92f 2005-01-04 devnull if(shellstack == nil){
68 9aa1c92f 2005-01-04 devnull fprint(2, "internal shellstack error\n");
72 9aa1c92f 2005-01-04 devnull s = shellstack;
73 9aa1c92f 2005-01-04 devnull shellstack = s->next;
74 9aa1c92f 2005-01-04 devnull shellt = s->t;
75 9aa1c92f 2005-01-04 devnull shellcmd = s->w;
76 c8b6342d 2005-01-13 devnull setvar("MKSHELL", shellcmd);