diff --git a/minishell.h b/bozoshell.h similarity index 88% rename from minishell.h rename to bozoshell.h index 5e6ee2c..85bde9e 100644 --- a/minishell.h +++ b/bozoshell.h @@ -1,17 +1,17 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* minishell.h :+: :+: :+: */ +/* bozoshell.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: cchauvet next != NULL) { - write(fd, "declare -x ", 11); - ft_putstr_fd(((t_env *)(current->content))->key, fd); - if (((t_env *)(current->content))->value != NULL) + if (ft_strcmp(((t_env *)(current->content))->key, "_")) { - ft_putstr_fd("=", fd); - write(fd, "\"", 1); - ft_putstr_fd(((t_env *)(current->content))->value, fd); - write(fd, "\"\n", 2); + write(fd, "declare -x ", 11); + ft_putstr_fd(((t_env *)(current->content))->key, fd); + if (((t_env *)(current->content))->value != NULL) + { + ft_putstr_fd("=", fd); + write(fd, "\"", 1); + ft_putstr_fd(((t_env *)(current->content))->value, fd); + write(fd, "\"\n", 2); + } + else + write(fd, "\n", 2); } - else - write(fd, "\n", 2); current = current->next; } } diff --git a/env/env_fill.c b/env/env_fill.c index 7496019..34182cb 100644 --- a/env/env_fill.c +++ b/env/env_fill.c @@ -31,7 +31,7 @@ static char *ft_getkey(const char *str) key = ft_strndup(str + 1, i - 1); } if (key == NULL) - ft_eprintf("minishell: malloc failed\n"); + ft_eprintf("bozoshell: malloc failed\n"); return (key); } @@ -54,7 +54,7 @@ static char *ft_getvalue(t_data *data, char *key) value = ft_strdup(value); } if (value == NULL) - ft_eprintf("minishell: malloc failed\n"); + ft_eprintf("bozoshell: malloc failed\n"); return (value); } diff --git a/format/format.c b/format/format.c index c7db08e..9d688d9 100644 --- a/format/format.c +++ b/format/format.c @@ -20,7 +20,7 @@ static int ft_replace(char **str, size_t i) free(*str); if (temp == NULL) { - ft_eprintf("minishell: malloc failed\n"); + ft_eprintf("bozoshell: malloc failed\n"); return (1); } *str = temp; diff --git a/main.c b/main.c index 7019673..50b2db6 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: cchauvet @@ -32,7 +32,7 @@ static char *ft_get_user_input(void) free(pwd); if (prompt == NULL) { - ft_eprintf("minishell: malloc failed\n"); + ft_eprintf("bozoshell: malloc failed\n"); return (NULL); } line = readline(prompt); @@ -72,14 +72,14 @@ int ft_init_data(t_data *data, char **env) data->cmds = malloc(sizeof(t_cmd *)); if (data->cmds == NULL) { - ft_eprintf("minishell: malloc failed\n"); + ft_eprintf("bozoshell: malloc failed\n"); return (1); } *data->cmds = NULL; data->env = init_env(env); if (data->env == NULL) { - ft_eprintf("minishell: malloc failed\n"); + ft_eprintf("bozoshell: malloc failed\n"); free(data->cmds); return (1); } diff --git a/parse/parse.c b/parse/parse.c index 2eac22e..a1242fe 100644 --- a/parse/parse.c +++ b/parse/parse.c @@ -80,7 +80,7 @@ int ft_cmd_parser(t_data *data, char *cmd_str) cmd = ft_calloc(sizeof(t_cmd), 1); if (cmd == NULL) { - ft_eprintf("minishell: malloc failed\n"); + ft_eprintf("bozoshell: malloc failed\n"); return (1); } if (ft_redirection(data, cmd, cmd_str)) @@ -105,7 +105,7 @@ int ft_cmds_parser(t_data *data, const char *line) tab = ft_split_charset_quoted(line, "|"); if (tab == NULL) { - ft_eprintf("minishell: malloc failed\n"); + ft_eprintf("bozoshell: malloc failed\n"); return (1); } i = -1; diff --git a/redirection/check.c b/redirection/check.c index cf2b3f6..81407e5 100644 --- a/redirection/check.c +++ b/redirection/check.c @@ -126,13 +126,13 @@ bool ft_check_redirection(t_data *data, t_cmd *cmd, if (ft_is_in("<>", redirection_identifier[0]) && ft_is_in("<>", redirection[0])) { - ft_eprintf("minishell: %s: invalid redirection file\n", redirection); + ft_eprintf("bozoshell: %s: invalid redirection file\n", redirection); return (1); } str = ft_strdup(redirection); if (str == NULL) { - ft_eprintf("minishell: malloc failed\n"); + ft_eprintf("bozoshell: malloc failed\n"); return (1); } ft_quote_remover(str); diff --git a/redirection/file.c b/redirection/file.c index d7604b4..9a93bc4 100644 --- a/redirection/file.c +++ b/redirection/file.c @@ -21,14 +21,14 @@ int ft_file_is_readable(t_data *data, const char *path) if (fd == -1) { *data->exit_code = 1; - ft_eprintf("minishell: %s: No such file or directory\n", path); + ft_eprintf("bozoshell: %s: No such file or directory\n", path); return (0); } readable = read(fd, "", 0); if (readable == -1) { *data->exit_code = 1; - ft_eprintf("minishell: %s: Permission denied\n", path); + ft_eprintf("bozoshell: %s: Permission denied\n", path); return (0); } close(fd); @@ -44,14 +44,14 @@ int ft_file_is_writable(t_data *data, const char *path) if (fd == -1) { *data->exit_code = 1; - ft_eprintf("minishell: %s: Permission denied\n", path); + ft_eprintf("bozoshell: %s: Permission denied\n", path); return (0); } writeable = write(fd, "", 0); if (writeable == -1) { *data->exit_code = 1; - ft_eprintf("minishell: %s: Permission denied\n", path); + ft_eprintf("bozoshell: %s: Permission denied\n", path); return (0); } close(fd); @@ -67,14 +67,14 @@ int ft_file_is_appendable(t_data *data, const char *path) if (fd == -1) { *data->exit_code = 1; - ft_eprintf("minishell: %s: Permission denied\n", path); + ft_eprintf("bozoshell: %s: Permission denied\n", path); return (0); } writeable = write(fd, "", 0); if (writeable == -1) { *data->exit_code = 1; - ft_eprintf("minishell: %s: Permission denied\n", path); + ft_eprintf("bozoshell: %s: Permission denied\n", path); return (0); } close(fd); diff --git a/redirection/heredoc.c b/redirection/heredoc.c index cbf8e25..7feb079 100644 --- a/redirection/heredoc.c +++ b/redirection/heredoc.c @@ -41,7 +41,7 @@ static int ft_heredoc3(char *stop, int fds[2]) } else { - ft_eprintf("minishell: warning: here-document at line"); + ft_eprintf("bozoshell: warning: here-document at line"); ft_eprintf("1 delimited by end-of-file (wanted `%s')\n", stop); return (2); } diff --git a/redirection/redirection.c b/redirection/redirection.c index 834e163..279e0af 100644 --- a/redirection/redirection.c +++ b/redirection/redirection.c @@ -84,7 +84,7 @@ int ft_set_redirection(t_data *data, t_cmd *cmd, char **tab) } if (ft_is_in("<>", tab[i][0])) { - ft_eprintf("minishell: %s: must be followed by a file\n", tab[i]); + ft_eprintf("bozoshell: %s: must be followed by a file\n", tab[i]); return (1); } return (0); @@ -101,7 +101,7 @@ int ft_redirection(t_data *data, t_cmd *cmd, char *cmd_str) tab = ft_split_charset_quoted(cmd_str, " \t"); if (tab == NULL) { - ft_eprintf("minishell: malloc failed\n"); + ft_eprintf("bozoshell: malloc failed\n"); return (1); } ft_remove_redirection(cmd_str); diff --git a/syntax/syntax.c b/syntax/syntax.c index a786bb5..f8e88ad 100644 --- a/syntax/syntax.c +++ b/syntax/syntax.c @@ -17,7 +17,7 @@ static int ft_quote_verif(const char *str) { if (ft_is_in_quote(str, ft_strlen(str))) { - ft_eprintf("minishell: Quote is not closed\n"); + ft_eprintf("bozoshell: Quote is not closed\n"); return (1); } else @@ -47,7 +47,7 @@ static int ft_pipe_is_alone(const char *str) } } if (check == 0) - ft_eprintf("minishell: Pipe must be followed and %s", + ft_eprintf("bozoshell: Pipe must be followed and %s", "preced by a command or redirection\n"); return (check == 0); } @@ -70,7 +70,7 @@ static int ft_special_char_dub(const char *str) if ((y > 2 && (str[i] == '>' || str[i] == '<')) || (y > 1 && str[i] == '|')) { - ft_eprintf("minishell: too many %s in a row\n", str); + ft_eprintf("bozoshell: too many %s in a row\n", str); return (1); } i = i + y; diff --git a/utils/ft_change_exit_code.c b/utils/ft_change_exit_code.c index adf900b..a209856 100644 --- a/utils/ft_change_exit_code.c +++ b/utils/ft_change_exit_code.c @@ -20,7 +20,7 @@ int ft_change_exit_code(t_data *data, int new_value) exit_code_str = ft_itoa(new_value); if (exit_code_str == NULL) { - ft_eprintf("minishell: malloc failed\n"); + ft_eprintf("bozoshell: malloc failed\n"); return (1); } return (0); diff --git a/utils/ft_get_executable.c b/utils/ft_get_executable.c index 4e9c8f1..3878d41 100644 --- a/utils/ft_get_executable.c +++ b/utils/ft_get_executable.c @@ -20,19 +20,19 @@ char *ft_get_executable_with_path(t_data *data, const char *name) if (access(name, F_OK) != 0) { *data->exit_code = 127; - ft_eprintf("minishell: %s: No such file or directery\n", name); + ft_eprintf("bozoshell: %s: No such file or directery\n", name); return (NULL); } if (access(name, X_OK) != 0) { *data->exit_code = 126; - ft_eprintf("minishell: %s: permission denied\n", name); + ft_eprintf("bozoshell: %s: permission denied\n", name); return (NULL); } path = ft_strdup(name); if (path == NULL) { - ft_eprintf("minishell: malloc failed\n"); + ft_eprintf("bozoshell: malloc failed\n"); return (NULL); } return (path); @@ -47,13 +47,13 @@ static char **ft_get_paths(t_data *data, const char *name) if (paths == NULL) { *data->exit_code = 127; - ft_eprintf("minishell: %s: command not found\n", name); + ft_eprintf("bozoshell: %s: command not found\n", name); return (NULL); } tab = ft_split(paths, ':'); if (tab == NULL) { - ft_eprintf("minishell: malloc failed\n"); + ft_eprintf("bozoshell: malloc failed\n"); return (NULL); } return (tab); @@ -66,7 +66,7 @@ static char *ft_file_is_executable(const char *path, const char *name) out = ft_strmerger(3, path, "/", name); if (out == NULL) { - ft_eprintf("minishell: malloc failed\n"); + ft_eprintf("bozoshell: malloc failed\n"); free(out); return (NULL); } @@ -98,7 +98,7 @@ static char *ft_get_executable_without_path(t_data *data, const char *name) if (path == NULL) { *data->exit_code = 127; - ft_eprintf("minishell: %s: command not found\n", name); + ft_eprintf("bozoshell: %s: command not found\n", name); } return (path); }