Commit 00c04a6f authored by pêle-mêle's avatar pêle-mêle
Browse files

more adjustments

parent 160b7731
......@@ -6,7 +6,7 @@
#include <sys/types.h> // waitpid
#include <sys/wait.h> // waitpid
#include <fcntl.h>
#include <fcntl.h> // open
static int handle_eof(char **line, int ret)
{
......@@ -67,19 +67,22 @@ static int main_loop(t_xe *xe)
int exec_env_init(t_xe *xe, char **env_source)
{
char *shlvl;
char *val;
int tmp;
xe->env = dup_str_array(env_source);
xe->child = 0;
if (xe->env == NULL)
return (MALLOC_ERR);
shlvl = get_var_value(xe->env, SHLVL_STR, ft_strlen(SHLVL_STR));
// printf("shlvl = %s\n", shlvl);
if (shlvl == NULL)
return (MALLOC_ERR);
tmp = ft_atoi(shlvl);
free(shlvl);
tmp += 1;
val = ft_itoa(tmp);
env_replace_var(SHLVL_STR, val, xe);
shlvl = ft_itoa(tmp);
if (shlvl == NULL)
return (MALLOC_ERR);
env_replace_var(SHLVL_STR, shlvl, xe);
free(shlvl);
xe->backup_stdin = dup(STDIN_FILENO);
xe->backup_stdout = dup(STDOUT_FILENO);
return (SUCCESS);
......@@ -122,7 +125,7 @@ int main(int argc, char **argv, char **env_source)
while (ret == SUCCESS)
ret = main_loop(xe);
}
else
else // merge with else if (argc == 2) ?
{
signal_handler(); // err?
ret = exec_env_init(xe, env_source);
......
......@@ -161,8 +161,6 @@ int parse_input(char **line, char **env, int stat_loc, t_command *command)
single_quote, double_quote, quoted_backslash, quoted_dollar, angle_bracket};
t_state_machine machine;
if ((*line)[0] == '.' && (*line)[1] == '\0')
exit(EXIT_FAILURE);
ft_bzero(&machine, sizeof(machine));
machine.env = env;
machine.stat_loc = stat_loc;
......@@ -184,9 +182,6 @@ int parse_input(char **line, char **env, int stat_loc, t_command *command)
return (AMBIG_REDIR);
return (FAILURE);
}
// ft_printarray_fd(machine.args, STDOUT_FILENO);
// printf("REDIR PATHS:\n");
// ft_printarray_fd(machine.redir_paths, STDOUT_FILENO);
return (SUCCESS);
}
......
Supports Markdown
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