1 9aa1c92f 2005-01-04 devnull #include "mk.h"
3 9aa1c92f 2005-01-04 devnull static Shell *shells[] = {
8 2222020e 2005-10-29 devnull Shell *shelldefault = &shshell;
10 9aa1c92f 2005-01-04 devnull Shell *shellt;
11 9aa1c92f 2005-01-04 devnull Word *shellcmd;
13 9aa1c92f 2005-01-04 devnull typedef struct Shellstack Shellstack;
14 9aa1c92f 2005-01-04 devnull struct Shellstack
16 9aa1c92f 2005-01-04 devnull Shell *t;
18 9aa1c92f 2005-01-04 devnull Shellstack *next;
21 9aa1c92f 2005-01-04 devnull Shellstack *shellstack;
24 9aa1c92f 2005-01-04 devnull setshell(Word *w)
28 9aa1c92f 2005-01-04 devnull if(w->s == nil)
29 9aa1c92f 2005-01-04 devnull return "shell name not found on line";
31 9aa1c92f 2005-01-04 devnull for(i=0; i<nelem(shells); i++)
32 9aa1c92f 2005-01-04 devnull if(shells[i]->matchname(w->s))
34 9aa1c92f 2005-01-04 devnull if(i == nelem(shells))
35 9aa1c92f 2005-01-04 devnull return "cannot determine shell type";
36 9aa1c92f 2005-01-04 devnull shellt = shells[i];
37 9aa1c92f 2005-01-04 devnull shellcmd = w;
38 9aa1c92f 2005-01-04 devnull return nil;
42 9aa1c92f 2005-01-04 devnull initshell(void)
44 e683bdfa 2021-10-05 crossd if(getenv("FORCERCFORMK") != nil)
45 e683bdfa 2021-10-05 crossd shelldefault = &rcshell;
46 2222020e 2005-10-29 devnull shellcmd = stow(shelldefault->name);
47 2222020e 2005-10-29 devnull shellt = shelldefault;
48 c8b6342d 2005-01-13 devnull setvar("MKSHELL", shellcmd);
52 9aa1c92f 2005-01-04 devnull pushshell(void)
54 9aa1c92f 2005-01-04 devnull Shellstack *s;
56 9aa1c92f 2005-01-04 devnull /* save */
57 9aa1c92f 2005-01-04 devnull s = Malloc(sizeof *s);
58 9aa1c92f 2005-01-04 devnull s->t = shellt;
59 9aa1c92f 2005-01-04 devnull s->w = shellcmd;
60 9aa1c92f 2005-01-04 devnull s->next = shellstack;
61 9aa1c92f 2005-01-04 devnull shellstack = s;
63 9aa1c92f 2005-01-04 devnull initshell(); /* reset to defaults */
67 9aa1c92f 2005-01-04 devnull popshell(void)
69 9aa1c92f 2005-01-04 devnull Shellstack *s;
71 9aa1c92f 2005-01-04 devnull if(shellstack == nil){
72 9aa1c92f 2005-01-04 devnull fprint(2, "internal shellstack error\n");
76 9aa1c92f 2005-01-04 devnull s = shellstack;
77 9aa1c92f 2005-01-04 devnull shellstack = s->next;
78 9aa1c92f 2005-01-04 devnull shellt = s->t;
79 9aa1c92f 2005-01-04 devnull shellcmd = s->w;
80 c8b6342d 2005-01-13 devnull setvar("MKSHELL", shellcmd);