Commit 09d7b304 authored by pêle-mêle's avatar pêle-mêle
Browse files

skip empty command that has empty vars inside

parent 3a7b7e9b
......@@ -92,7 +92,8 @@ typedef struct s_command
char **redir_paths;
enum e_redir_op *redir_types;
t_byte pipe_flag;
uint8_t pad[7];
t_byte var_flag;
uint8_t pad[6];
} t_command;
typedef struct s_xe
......
......@@ -43,9 +43,10 @@ typedef struct s_state_machine
enum e_state state;
int stat_loc;
t_byte pipe_flag;
t_byte var_flag;
t_byte var_state;
t_byte quote_state;
uint8_t pad[5];
uint8_t pad[4];
} t_state_machine;
typedef char *(*t_parse)(t_state_machine *, char *);
......
......@@ -132,7 +132,7 @@ int handle_execution(t_xe *xe, int fd_in, int proc)
return (handle_execution(xe, fd_in, proc));
}
}
if (cur_command->args != NULL)
if (cur_command->args != NULL || cur_command->var_flag == TRUE)
{
return (handle_command(cur_command, xe, fd_in, proc));
}
......
......@@ -6,7 +6,7 @@
/* By: mvidal-a <mvidal-a@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/01 11:25:06 by mvidal-a #+# #+# */
/* Updated: 2021/02/02 13:26:26 by mvidal-a ### ########.fr */
/* Updated: 2021/02/02 14:21:54 by mvidal-a ### ########.fr */
/* */
/* ************************************************************************** */
......@@ -32,6 +32,7 @@ int parse_input(char **line, char **env, int stat_loc,
}
free(machine.cur_arg);
command->pipe_flag = machine.pipe_flag;
command->var_flag = machine.var_flag;
command->redir_paths = machine.redir_paths;
command->redir_types = machine.redir_types;
command->args = machine.args;
......
......@@ -6,7 +6,7 @@
/* By: mvidal-a <mvidal-a@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/01/27 12:14:56 by mvidal-a #+# #+# */
/* Updated: 2021/02/01 11:24:26 by mvidal-a ### ########.fr */
/* Updated: 2021/02/02 14:21:26 by mvidal-a ### ########.fr */
/* */
/* ************************************************************************** */
......@@ -61,6 +61,7 @@ char *parse_variable(t_state_machine *machine, char *line)
free(var_value);
line += var_name_len;
machine->var_state = TRUE;
machine->var_flag = TRUE;
return (line);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment