changelog for 0.9.1
[posh.git] / tree.h
blob4264fe1e25a03c0e029087172b09c5b2e5f9bb15
1 /*
2 * command trees for compile/execute
3 */
5 /* $Id: tree.h,v 1.3 1994/05/31 13:34:34 michael Exp $ */
7 #define NOBLOCK ((struct op *)NULL)
8 #define NOWORD ((char *)NULL)
9 #define NOWORDS ((char **)NULL)
12 * Description of a command or an operation on commands.
14 struct op {
15 short type; /* operation type, see below */
16 short evalflags; /* TCOM: arg expansion eval() flags */
17 char **args; /* arguments to a command */
18 char **vars; /* variable assignments */
19 struct ioword **ioact; /* IO actions (eg, < > >>) */
20 struct op *left, *right; /* descendents */
21 char *str; /* word for case; identifier for for,
22 * select, and functions;
23 * path to execute for TEXEC;
24 * time hook for TCOM.
26 int lineno; /* TCOM/TFUNC: LINENO for this */
29 /* Tree.type values */
30 #define TEOF 0
31 #define TCOM 1 /* command */
32 #define TPAREN 2 /* (c-list) */
33 #define TPIPE 3 /* a | b */
34 #define TLIST 4 /* a ; b */
35 #define TOR 5 /* || */
36 #define TAND 6 /* && */
37 #define TBANG 7 /* ! */
38 #define TDBRACKET 8 /* [[ .. ]] */
39 #define TFOR 9
40 #define TSELECT 10
41 #define TCASE 11
42 #define TIF 12
43 #define TWHILE 13
44 #define TUNTIL 14
45 #define TELIF 15
46 #define TPAT 16 /* pattern in case */
47 #define TBRACE 17 /* {c-list} */
48 #define TASYNC 18 /* c & */
49 #define TFUNCT 19 /* function name { command; } */
50 #ifdef SILLY_FEATURES
51 #define TTIME 20 /* time pipeline */
52 #endif /* SILLY_FEATURES */
53 #define TEXEC 21 /* fork/exec eval'd TCOM */
54 #define TCOPROC 22 /* coprocess |& */
57 * prefix codes for words in command tree
59 #define EOS 0 /* end of string */
60 #define CHAR 1 /* unquoted character */
61 #define QCHAR 2 /* quoted character */
62 #define COMSUB 3 /* $() substitution (0 terminated) */
63 #define EXPRSUB 4 /* $(()) substitution (0 terminated) */
64 #define OQUOTE 5 /* opening " or ' */
65 #define CQUOTE 6 /* closing " or ' */
66 #define OSUBST 7 /* opening ${ subst (followed by { or X) */
67 #define CSUBST 8 /* closing } of above (followed by } or X) */
68 #define OPAT 9 /* open pattern: *(, @(, etc. */
69 #define SPAT 10 /* separate pattern: | */
70 #define CPAT 11 /* close pattern: ) */
73 * IO redirection
75 struct ioword {
76 int unit; /* unit affected */
77 int flag; /* action (below) */
78 char *name; /* file name (unused if heredoc) */
79 char *delim; /* delimiter for <<,<<- */
80 char *heredoc;/* content of heredoc */
83 /* ioword.flag - type of redirection */
84 #define IOTYPE 0xF /* type: bits 0:3 */
85 #define IOREAD 0x1 /* < */
86 #define IOWRITE 0x2 /* > */
87 #define IORDWR 0x3 /* <>: todo */
88 #define IOHERE 0x4 /* << (here file) */
89 #define IOCAT 0x5 /* >> */
90 #define IODUP 0x6 /* <&/>& */
91 #define IOEVAL BIT(4) /* expand in << */
92 #define IOSKIP BIT(5) /* <<-, skip ^\t* */
93 #define IOCLOB BIT(6) /* >|, override -o noclobber */
94 #define IORDUP BIT(7) /* x<&y (as opposed to x>&y) */
95 #define IONAMEXP BIT(8) /* name has been expanded */
97 /* execute/exchild flags */
98 #define XEXEC BIT(0) /* execute without forking */
99 #define XFORK BIT(1) /* fork before executing */
100 #define XBGND BIT(2) /* command & */
101 #define XPIPEI BIT(3) /* input is pipe */
102 #define XPIPEO BIT(4) /* output is pipe */
103 #define XPIPE (XPIPEI|XPIPEO) /* member of pipe */
104 #define XXCOM BIT(5) /* `...` command */
105 #define XPCLOSE BIT(6) /* exchild: close close_fd in parent */
106 #define XCCLOSE BIT(7) /* exchild: close close_fd in child */
107 #define XERROK BIT(8) /* non-zero exit ok (for set -e) */
108 #define XCOPROC BIT(9) /* starting a co-process */
109 #ifdef SILLY_FEATURES
110 #define XTIME BIT(10) /* timeing TCOM command */
111 #endif /* SILLY_FEATURES */
112 #define XINTACT BIT(11) /* OS2: proc started from interactive session */
115 * flags to control expansion of words (assumed by t->evalflags to fit
116 * in a short)
118 #define DOBLANK BIT(0) /* perform blank interpretation */
119 #define DOGLOB BIT(1) /* expand [?* */
120 #define DOPAT BIT(2) /* quote *?[ */
121 #define DOTILDE BIT(3) /* normal ~ expansion (first char) */
122 #define DONTRUNCOMMAND BIT(4) /* do not run $(command) things */
123 #define DOASNTILDE BIT(5) /* assignment ~ expansion (after =, :) */
124 #define DOBRACE_ BIT(6) /* used by expand(): do brace expansion */
125 #define DOMAGIC_ BIT(7) /* used by expand(): string contains MAGIC */
126 #define DOTEMP_ BIT(8) /* ditto : in word part of ${..[%#=?]..} */
127 #define DOVACHECK BIT(9) /* var assign check (for typeset, set, etc) */
128 #define DOMARKDIRS BIT(10) /* force markdirs behaviour */
131 * The arguments of [[ .. ]] expressions are kept in t->args[] and flags
132 * indicating how the arguments have been munged are kept in t->vars[].
133 * The contents of t->vars[] are stuffed strings (so they can be treated
134 * like all other t->vars[]) in which the second character is the one that
135 * is examined. The DB_* defines are the values for these second characters.
137 #define DB_NORM 1 /* normal argument */
138 #define DB_OR 2 /* || -> -o conversion */
139 #define DB_AND 3 /* && -> -a conversion */
140 #define DB_BE 4 /* an inserted -BE */
141 #define DB_PAT 5 /* a pattern argument */