Skip to content

Commit

Permalink
shorten function executor/input_utils.c
Browse files Browse the repository at this point in the history
  • Loading branch information
emSali committed Aug 13, 2023
1 parent 61ed7d2 commit d00e741
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
7 changes: 3 additions & 4 deletions executor/input_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* input_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: simao <simao@student.42.fr> +#+ +:+ +#+ */
/* By: esali <esali@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/07 16:01:24 by simao #+# #+# */
/* Updated: 2023/08/09 12:16:04 by simao ### ########.fr */
/* Updated: 2023/08/13 11:16:29 by esali ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -113,8 +113,7 @@ void input_to_input(t_list *cmd_node, int fd)
{
if (access(input_sign->next->token[0], R_OK) == -1)
{
ft_printf("%s: no such file or dir.\n", input_sign->next->token[0]);
get_data()->exit = 1;
print_dir_error(input_sign->next->token[0]);
return ;
}
if (its_input(input_sign->next->next))
Expand Down
9 changes: 6 additions & 3 deletions minishell.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: esali <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/20 17:16:06 by esali #+# #+# */
/* Updated: 2023/08/12 20:36:30 by esali ### ########.fr */
/* Updated: 2023/08/13 11:17:28 by esali ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -177,7 +177,6 @@ int is_built_in(char *token);
int replace_env_var(char *key, char *value);
void redirect_stdin_to_pipe(t_list *node);
void redirect_stdout_to_pipe(void);
void print_env_error(void);
void free_env(void);
int open_file(t_list *node);
int is_pipe(char *token);
Expand All @@ -186,10 +185,14 @@ int its_output(t_list *node);
int its_input(t_list *node);
int its_append(t_list *node);
int its_heredoc(t_list *node);
void print_export_error(char *msg);
int maxlen(char *s1, char *s2);
void increase_shlvl(void);

/* Error Handling*/
void print_export_error(char *msg);
void print_env_error(void);
void print_dir_error(char *dir);

/* File Handling */

void reset_original_std(void);
Expand Down
12 changes: 9 additions & 3 deletions utils/error_handling.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: esali <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/01 17:59:56 by smagalha #+# #+# */
/* Updated: 2023/08/10 19:46:42 by esali ### ########.fr */
/* Updated: 2023/08/13 11:16:02 by esali ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -19,8 +19,14 @@ void print_env_error(void)
return ;
}

void print_export_error(char *msg)
void print_export_error(char *command)
{
ft_printf("export: %s is not a valid identifier\n", msg);
ft_printf("export: %s is not a valid identifier\n", command);
get_data()->exit = 1;
}

void print_dir_error(char *dir)
{
ft_printf("%s: no such file or dir.\n", dir);
get_data()->exit = 1;
}

0 comments on commit d00e741

Please sign in to comment.