-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.h
More file actions
54 lines (46 loc) · 911 Bytes
/
command.h
File metadata and controls
54 lines (46 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef COMMAND_H
#define COMMAND_H
enum io_op
{
IO_INPUT, // "<"
IO_DUPIN, // "<&"
IO_IODUAL, // "<>"
IO_OUTPUT, // ">"
IO_DUPOUT, // ">&"
IO_APPEND, // ">>"
IO_CLOBBER, // ">|"
};
struct io_node
{
enum io_op op;
char *io_num;
char *word;
struct io_node *next;
};
enum command_type
{
CMD_AND, // A && B
CMD_SEQUENCE, // A ; B
CMD_OR, // A || B
CMD_PIPE, // A | B
CMD_SIMPLE, // a simple command
CMD_SUBSHELL, // ( A )
};
struct command
{
enum command_type type;
// Exit status, or -1 if not known (e.g., because it has not exited yet).
int status;
int io_count;
struct io_node *io_head;
struct io_node *io_tail;
union
{
struct command *command[2];
struct command *subshell_command;
char **word;
} u;
};
typedef struct command *command_t;
typedef struct io_node *io_node_t;
#endif