myshellin/report/code/loop.txt

26 lines
535 B
Plaintext
Raw Normal View History

void loop() {
while (1) {
print_input_line();
char *line = get_console_input();
StringArray args;
create_string_array(&args);
char *saveptr = NULL;
char *token = strtok_r(line, " ", &saveptr);
while (token) {
insert_string_array(&args, token);
token = strtok_r(NULL, " ", &saveptr);
}
if (args.size == 0) {
continue;
}
if (is_builtin(args.array[0])) {
run_builtin(&args);
}
}
}