-
Notifications
You must be signed in to change notification settings - Fork 0
proj_shell
Jihun Kim edited this page Mar 29, 2019
·
3 revisions
Simple shell writed in C.
A struct representing a single command.
The string stored in cmd
is same with that of argv[0]
.
argv[argc]
must point NULL
.
struct Command {
char * cmd;
char ** argv;
size_t argc;
size_t argv_size;
pid_t pid;
};
vector of Command *
.
Last element of CommandVec
must point null
.
typedef Command ** CommandVec;
reads a single line from infile
. The function can read long line.
char * read_line(FILE * infile);
Parse a single line to CommandVec
.
CommandVec parse_line(char * line);
line
can be changed while parsing.
Parse given command_string
, and convert it to Command
.
command_string
must contain only one command.
Command * parse_command(const char * command_string);
If command_string
is a whitespace string or empty string, return NULL
.
Executes commands in command_vec
.
If any of command in command_vec
, function returns non-zero value.
int exec_commands(const CommandVec command_vec);
Helper function for deallocate memory of CommandVec
.
void free_command_vec(CommandVec command_vec);