Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
clean: replace bash by minishell
Browse files Browse the repository at this point in the history
  • Loading branch information
mahautlatinis committed Sep 20, 2024
1 parent 4acb54c commit b03e8b6
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 15 deletions.
1 change: 1 addition & 0 deletions minishell/file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test
4 changes: 2 additions & 2 deletions minishell/srcs/execution/builtins/cd/cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int sub_execute_cd_args(t_cmd_elem *elem, t_mem *mem, char *current_path)
new_pwd = NULL;
if (chdir(elem->args[1]) == -1)
{
ft_putstr_fd("bash: cd: ", 2);
ft_putstr_fd("minishell: cd: ", 2);
ft_putstr_fd(elem->args[1], 2);
ft_putstr_fd(": No such file or directory\n", 2);
push_ret_elem(mem, 127);
Expand All @@ -45,7 +45,7 @@ int execute_cd_args(t_cmd_elem *elem, t_mem *mem, char *current_path)
ret = 0;
new_pwd = NULL;
if (elem->args_len > 2)
return (d_err_p_ret("bash: cd: too many arguments\n", mem, 1, 2));
return (d_err_p_ret("minishell: cd: too many arguments\n", mem, 1, 2));
if (elem->args[1][0] != '-')
return (sub_execute_cd_args(elem, mem, current_path));
else
Expand Down
2 changes: 1 addition & 1 deletion minishell/srcs/execution/builtins/exit/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ int ft_exec_exit(t_cmd_elem *e, t_mem *m)
}
}
if (e && e->args_len > 2 && !enter)
return (d_err_p_ret("bash: exit: too many arguments\n", m, 1, 2));
return (d_err_p_ret("minishell: exit: too many arguments\n", m, 1, 2));
return (exit_clean(e, ret, m));
}
2 changes: 1 addition & 1 deletion minishell/srcs/execution/redirections/find_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ char *find_exec(t_cmd_elem *elem, t_mem *mem)
fd = open(s, O_RDONLY, 0644);
if (fd < 0)
{
ft_putstr_fd("bash: ", 2);
ft_putstr_fd("minishell: ", 2);
ft_putstr_fd(s, 2);
ft_putstr_fd(": No such file or directory\n", 2);
push_ret_elem(mem, 127);
Expand Down
2 changes: 1 addition & 1 deletion minishell/srcs/execution/redirections/heredoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void loop_heredoc(char *line, t_mem *mem, t_file_elem *f, int *heredoc_pipe)
line = readline("> ");
if (!line)
{
ft_putstr_fd("bash: avertissement : « here-document »\n", 2);
ft_putstr_fd("minishell: avertissement : « here-document »\n", 2);
break ;
}
if (!ft_strcmp(line, f->path))
Expand Down
2 changes: 1 addition & 1 deletion minishell/srcs/execution/redirections/redirections.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int redir_input_simple(t_cmd_elem *elem, t_mem *mem)
f->fd = open(f->path, O_RDONLY);
if (f->fd < 0)
{
ft_putstr_fd("bash: ", 2);
ft_putstr_fd("minishell: ", 2);
ft_putstr_fd(f->path, 2);
ft_putstr_fd(": No such file or directory\n", 2);
push_ret_elem(mem, 127);
Expand Down
3 changes: 0 additions & 3 deletions minishell/srcs/parsing/parse_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ int parse_line(t_mem *m)
else if (m->line[(p.i)++])
(*m->buffer) = copy_in_buffer((*m->buffer), m->line[p.i - 1], m);
if (p.error)
{
d_err_p_ret("inishell: parse error\n", m, 2, 2);
return (-1);
}
}
end_arg(m->buffer, p.e, m, &p.r_type);
if (check_parsing_end_conditions(m, &ret) < 0)
Expand Down
4 changes: 1 addition & 3 deletions minishell/srcs/parsing/parse_main_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ int check_parsing_end_conditions(t_mem *mem, int *ret)
*ret = 1;
if (check_cmd(mem->cmd) == -1)
{
ft_putstr_fd("Parse error.\n", 2);
push_ret_elem(mem, 2);
*ret = -1;
}
Expand Down Expand Up @@ -70,13 +69,12 @@ int check_file(t_mem *mem)
file_elem = elem->file->first;
if (elem->redir_type != R_NONE && !file_elem)
{
ft_putstr_fd("minishell: parse error\n", 2);
push_ret_elem(mem, 1);
return (-1);
}
else if (elem->redir_type != R_NONE && !ft_strcmp(file_elem->path, ""))
{
ft_putstr_fd("bash: No such file or directory\n", 2);
ft_putstr_fd("minishell: No such file or directory\n", 2);
push_ret_elem(mem, 127);
return (-2);
}
Expand Down
6 changes: 3 additions & 3 deletions minishell/srcs/utils/error/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int d2_err_p_ret(char *error, char *arg, t_mem *mem, int ret)

int d3_err(char *error, char *arg, t_mem *mem, int ret)
{
ft_putstr_fd("bash: ", 2);
ft_putstr_fd("minishell: ", 2);
ft_putstr_fd(arg, 2);
ft_putstr_fd(error, 2);
push_ret_elem(mem, ret);
Expand All @@ -40,7 +40,7 @@ int d3_err(char *error, char *arg, t_mem *mem, int ret)

int d4_err_p_ret(char *error, char *arg, t_mem *mem, int ret)
{
ft_putstr_fd("bash: exit: ", 2);
ft_putstr_fd("minishell: exit: ", 2);
ft_putstr_fd(arg, 2);
ft_putstr_fd(error, 2);
push_ret_elem(mem, ret);
Expand All @@ -49,7 +49,7 @@ int d4_err_p_ret(char *error, char *arg, t_mem *mem, int ret)

int d5_err_p_ret(char *error, char *arg, t_mem *mem, int ret)
{
ft_putstr_fd("bash: export: `", 2);
ft_putstr_fd("minishell: export: `", 2);
ft_putstr_fd(arg, 2);
ft_putstr_fd(error, 2);
push_ret_elem(mem, ret);
Expand Down

0 comments on commit b03e8b6

Please sign in to comment.