Skip to content
Snippets Groups Projects
Commit 7934b809 authored by Jaegeon's avatar Jaegeon
Browse files

fix | parsig

parent 1a75c6e3
No related branches found
No related tags found
No related merge requests found
...@@ -45,7 +45,7 @@ static int is_built_in_command(const char* command_name) ...@@ -45,7 +45,7 @@ static int is_built_in_command(const char* command_name)
*/ */
int evaluate_command(int n_commands, struct single_command (*commands)[512], struct pidStorage *ps) int evaluate_command(int n_commands, struct single_command (*commands)[512], struct pidStorage *ps)
{ {
int ti, status, i, j, n; int ti, status, i, j, n, re_i;
pid_t p_id; pid_t p_id;
char tmp_path[PATH_MAX]; char tmp_path[PATH_MAX];
struct aliased_command** aliased_commands; struct aliased_command** aliased_commands;
...@@ -53,7 +53,6 @@ int evaluate_command(int n_commands, struct single_command (*commands)[512], str ...@@ -53,7 +53,6 @@ int evaluate_command(int n_commands, struct single_command (*commands)[512], str
while (n_commands > ti) { while (n_commands > ti) {
struct single_command* com = (*commands) + ti++; struct single_command* com = (*commands) + ti++;
assert(com->argc != 0); assert(com->argc != 0);
n = get_no_alias(); n = get_no_alias();
...@@ -89,7 +88,9 @@ int evaluate_command(int n_commands, struct single_command (*commands)[512], str ...@@ -89,7 +88,9 @@ int evaluate_command(int n_commands, struct single_command (*commands)[512], str
ps->pid_arr[ps->arr_i][ps->arr_n++] = p_id; ps->pid_arr[ps->arr_i][ps->arr_n++] = p_id;
} }
} else { } else {
return exute_command(com, tmp_path, ps); re_i = exute_command(com, tmp_path, ps);
if(re_i)
return re_i;
} }
} }
return 0; return 0;
......
...@@ -23,6 +23,7 @@ void mysh_parse_command(const char* command, ...@@ -23,6 +23,7 @@ void mysh_parse_command(const char* command,
++ti; ++ti;
tok = strtok_r(NULL, "|", &saveptr); tok = strtok_r(NULL, "|", &saveptr);
} }
*n_commands = ti; *n_commands = ti;
...@@ -46,7 +47,13 @@ void parse_single_command(const char* command, ...@@ -46,7 +47,13 @@ void parse_single_command(const char* command,
flag = 0; flag = 0;
point = command[command_i++]; point = command[command_i++];
while(point != '\n'){ while(1){
if(point == '\n' || point == '\0')
break;
else if(buf_i == 0 && point == ' '){
point = command[command_i++];
continue;
}
buf[buf_i++] = point; buf[buf_i++] = point;
if(!flag && point == ' '){ if(!flag && point == ' '){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment