1*46439007SCharles.ForsythCommand: module 2*46439007SCharles.Forsyth{ 3*46439007SCharles.Forsyth PATH: con "/dis/sh.dis"; 4*46439007SCharles.Forsyth 5*46439007SCharles.Forsyth init: fn(ctxt: ref Draw->Context, argv: list of string); 6*46439007SCharles.Forsyth}; 7*46439007SCharles.Forsyth 8*46439007SCharles.ForsythSh: module 9*46439007SCharles.Forsyth{ 10*46439007SCharles.Forsyth PATH: con "/dis/sh.dis"; 11*46439007SCharles.Forsyth initialise: fn(); 12*46439007SCharles.Forsyth init: fn(ctxt: ref Draw->Context, argv: list of string); 13*46439007SCharles.Forsyth system: fn(drawctxt: ref Draw->Context, cmd: string): string; 14*46439007SCharles.Forsyth run: fn(drawctxt: ref Draw->Context, argv: list of string): string; 15*46439007SCharles.Forsyth parse: fn(s: string): (ref Cmd, string); 16*46439007SCharles.Forsyth cmd2string: fn(c: ref Cmd): string; 17*46439007SCharles.Forsyth 18*46439007SCharles.Forsyth Context: adt { 19*46439007SCharles.Forsyth new: fn(drawcontext: ref Draw->Context): ref Context; 20*46439007SCharles.Forsyth get: fn(c: self ref Context, name: string): list of ref Listnode; 21*46439007SCharles.Forsyth set: fn(c: self ref Context, name: string, val: list of ref Listnode); 22*46439007SCharles.Forsyth setlocal: fn(c: self ref Context, name: string, val: list of ref Listnode); 23*46439007SCharles.Forsyth envlist: fn(c: self ref Context): list of (string, list of ref Listnode); 24*46439007SCharles.Forsyth push: fn(c: self ref Context); 25*46439007SCharles.Forsyth pop: fn(c: self ref Context); 26*46439007SCharles.Forsyth copy: fn(c: self ref Context, copyenv: int): ref Context; 27*46439007SCharles.Forsyth run: fn(c: self ref Context, args: list of ref Listnode, last: int): string; 28*46439007SCharles.Forsyth addmodule: fn(c: self ref Context, name: string, mod: Shellbuiltin); 29*46439007SCharles.Forsyth addbuiltin: fn(c: self ref Context, name: string, mod: Shellbuiltin); 30*46439007SCharles.Forsyth removebuiltin: fn(c: self ref Context, name: string, mod: Shellbuiltin); 31*46439007SCharles.Forsyth addsbuiltin: fn(c: self ref Context, name: string, mod: Shellbuiltin); 32*46439007SCharles.Forsyth removesbuiltin: fn(c: self ref Context, name: string, mod: Shellbuiltin); 33*46439007SCharles.Forsyth fail: fn(c: self ref Context, ename, msg: string); 34*46439007SCharles.Forsyth options: fn(c: self ref Context): int; 35*46439007SCharles.Forsyth setoptions: fn(c: self ref Context, flags, on: int): int; 36*46439007SCharles.Forsyth INTERACTIVE, VERBOSE, EXECPRINT, ERROREXIT: con 1 << iota; 37*46439007SCharles.Forsyth 38*46439007SCharles.Forsyth env: ref Environment; 39*46439007SCharles.Forsyth waitfd: ref Sys->FD; 40*46439007SCharles.Forsyth drawcontext: ref Draw->Context; 41*46439007SCharles.Forsyth keepfds: list of int; 42*46439007SCharles.Forsyth }; 43*46439007SCharles.Forsyth 44*46439007SCharles.Forsyth list2stringlist: fn(nl: list of ref Listnode): list of string; 45*46439007SCharles.Forsyth stringlist2list: fn(sl: list of string): list of ref Listnode; 46*46439007SCharles.Forsyth quoted: fn(val: list of ref Listnode, quoteblocks: int): string; 47*46439007SCharles.Forsyth 48*46439007SCharles.Forsyth initbuiltin: fn(c: ref Context, sh: Sh): string; 49*46439007SCharles.Forsyth whatis: fn(nil: ref Sh->Context, nil: Sh, nil: string, nil: int): string; 50*46439007SCharles.Forsyth runbuiltin: fn(c: ref Context, sh: Sh, cmd: list of ref Listnode, last: int): string; 51*46439007SCharles.Forsyth runsbuiltin: fn(c: ref Context, sh: Sh, cmd: list of ref Listnode): list of ref Listnode; 52*46439007SCharles.Forsyth getself: fn(): Shellbuiltin; 53*46439007SCharles.Forsyth Cmd: type Node; 54*46439007SCharles.Forsyth Node: adt { 55*46439007SCharles.Forsyth ntype: int; 56*46439007SCharles.Forsyth left, right: ref Node; 57*46439007SCharles.Forsyth word: string; 58*46439007SCharles.Forsyth redir: ref Redir; 59*46439007SCharles.Forsyth }; 60*46439007SCharles.Forsyth Redir: adt { 61*46439007SCharles.Forsyth rtype: int; 62*46439007SCharles.Forsyth fd1, fd2: int; 63*46439007SCharles.Forsyth }; 64*46439007SCharles.Forsyth Var: adt { 65*46439007SCharles.Forsyth name: string; 66*46439007SCharles.Forsyth val: list of ref Listnode; 67*46439007SCharles.Forsyth flags: int; 68*46439007SCharles.Forsyth CHANGED, NOEXPORT: con (1 << iota); 69*46439007SCharles.Forsyth }; 70*46439007SCharles.Forsyth Environment: adt { 71*46439007SCharles.Forsyth sbuiltins: ref Builtins; 72*46439007SCharles.Forsyth builtins: ref Builtins; 73*46439007SCharles.Forsyth bmods: list of (string, Shellbuiltin); 74*46439007SCharles.Forsyth localenv: ref Localenv; 75*46439007SCharles.Forsyth }; 76*46439007SCharles.Forsyth Localenv: adt { 77*46439007SCharles.Forsyth vars: array of list of ref Var; 78*46439007SCharles.Forsyth pushed: ref Localenv; 79*46439007SCharles.Forsyth flags: int; 80*46439007SCharles.Forsyth }; 81*46439007SCharles.Forsyth Listnode: adt { 82*46439007SCharles.Forsyth cmd: ref Node; 83*46439007SCharles.Forsyth word: string; 84*46439007SCharles.Forsyth }; 85*46439007SCharles.Forsyth Builtins: adt { 86*46439007SCharles.Forsyth ba: array of (string, list of Shellbuiltin); 87*46439007SCharles.Forsyth n: int; 88*46439007SCharles.Forsyth }; 89*46439007SCharles.Forsyth # node types 90*46439007SCharles.Forsyth n_BLOCK, n_VAR, n_BQ, n_BQ2, n_REDIR, 91*46439007SCharles.Forsyth n_DUP, n_LIST, n_SEQ, n_CONCAT, n_PIPE, n_ADJ, 92*46439007SCharles.Forsyth n_WORD, n_NOWAIT, n_SQUASH, n_COUNT, 93*46439007SCharles.Forsyth n_ASSIGN, n_LOCAL: con iota; 94*46439007SCharles.Forsyth GLOB: con 1; 95*46439007SCharles.Forsyth}; 96*46439007SCharles.Forsyth 97*46439007SCharles.ForsythShellbuiltin: module { 98*46439007SCharles.Forsyth initbuiltin: fn(c: ref Sh->Context, sh: Sh): string; 99*46439007SCharles.Forsyth runbuiltin: fn(c: ref Sh->Context, sh: Sh, 100*46439007SCharles.Forsyth cmd: list of ref Sh->Listnode, last: int): string; 101*46439007SCharles.Forsyth runsbuiltin: fn(c: ref Sh->Context, sh: Sh, 102*46439007SCharles.Forsyth cmd: list of ref Sh->Listnode): list of ref Sh->Listnode; 103*46439007SCharles.Forsyth BUILTIN, SBUILTIN, OTHER: con iota; 104*46439007SCharles.Forsyth whatis: fn(c: ref Sh->Context, sh: Sh, name: string, wtype: int): string; 105*46439007SCharles.Forsyth getself: fn(): Shellbuiltin; 106*46439007SCharles.Forsyth}; 107