deux tours ont despawn dans les backrooms le 11 septembres

This commit is contained in:
Etienne Rey-bethbeder 2023-02-21 15:44:43 +01:00
commit 4c45a2c603
5 changed files with 49 additions and 22 deletions

View File

@ -6,7 +6,7 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */ /* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/17 16:09:11 by erey-bet #+# #+# */ /* Created: 2023/02/17 16:09:11 by erey-bet #+# #+# */
/* Updated: 2023/02/21 14:34:50 by erey-bet ### ########.fr */ /* Updated: 2023/02/21 15:11:38 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,10 +17,10 @@ int pwd(int fd)
char path[PATH_MAX]; char path[PATH_MAX];
if (getcwd(path, sizeof(path)) != NULL) if (getcwd(path, sizeof(path)) != NULL)
ft_putstr_fd(path, fd); ft_putendl_fd(path, fd);
else else
{ {
ft_putstr_fd("Error getcwd", fd); ft_putendl_fd("Error getcwd", fd);
return (1); return (1);
} }
return (0); return (0);
@ -35,7 +35,7 @@ char *get_pwd(int fd)
return (str); return (str);
else else
{ {
ft_putstr_fd("Error getcwd", fd); ft_putendl_fd("Error getcwd", fd);
return (NULL); return (NULL);
} }
} }

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/21 12:45:16 by cchauvet #+# #+# */ /* Created: 2023/02/21 12:45:16 by cchauvet #+# #+# */
/* Updated: 2023/02/21 13:48:39 by cchauvet ### ########.fr */ /* Updated: 2023/02/21 15:31:02 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -20,6 +20,8 @@ static char *ft_get_executable_path(char *executable_name, t_list **env)
char **tab; char **tab;
size_t i; size_t i;
if (executable_name == NULL)
return (NULL);
path = NULL; path = NULL;
if (executable_name[0] == '.' || executable_name[0] == '/') if (executable_name[0] == '.' || executable_name[0] == '/')
{ {
@ -95,21 +97,26 @@ static int ft_excutor(t_cmd *cmd, t_list **env)
static int ft_own_cmd(t_list **env, t_cmd *cmd) static int ft_own_cmd(t_list **env, t_cmd *cmd)
{ {
/* if (ft_strcmp(cmd->executable, "pwd") == 0) */ int return_code;
/* return (pwd(env, cmd->fd_out)); */
if (ft_strcmp(cmd->executable, "env") == 0) return_code = -1;
return (print_env(env, cmd->fd_out)); if (ft_strcmp(cmd->executable, "pwd") == 0)
if (ft_strcmp(cmd->executable, "export") == 0) return_code = pwd(cmd->fd_out);
return (print_export(env, cmd->fd_out)); else if (ft_strcmp(cmd->executable, "env") == 0)
/* if (ft_strcmp(cmd->executable, "cd") == 0) */ return_code = print_env(env, cmd->fd_out);
/* return (move_folder(cmd->args[0], cmd->fd_out)); */ else if (ft_strcmp(cmd->executable, "export") == 0)
return_code = (print_export(env, cmd->fd_out));
else if (ft_strcmp(cmd->executable, "cd") == 0)
return_code = (move_folder(cmd->args[0], cmd->fd_out));
/* if (ft_strcmp(cmd->executable, "unset") == 0) */ /* if (ft_strcmp(cmd->executable, "unset") == 0) */
/* return (unset(env, cmd->args, cmd->fd_out)); */ /* return_code = (unset(env, cmd->args, cmd->fd_out)); */
/* if (ft_strcmp(cmd->executable, "echo") == 0) */ /* else if (ft_strcmp(cmd->executable, "echo") == 0) */
/* return (echo(cmd->fd_out, cmd->args[0])); */ /* return_code = (echo(cmd->fd_out, cmd->args + 1)); */
if (ft_strcmp(cmd->executable, "exit") == 0) else if (ft_strcmp(cmd->executable, "exit") == 0)
return (-2); return_code = -2;
return (-1); if (return_code != -1)
cmd->executable = NULL;
return (return_code);
} }
int ft_cmds_executor(t_list **cmds, t_list **env) int ft_cmds_executor(t_list **cmds, t_list **env)

9
main.c
View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */ /* Created: 2023/02/16 15:16:14 by cchauvet #+# #+# */
/* Updated: 2023/02/21 14:24:45 by cchauvet ### ########.fr */ /* Updated: 2023/02/21 14:48:07 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -17,8 +17,13 @@ static char *ft_get_user_input(t_list **env)
{ {
char *line; char *line;
char *prompt; char *prompt;
char *pwd;
prompt = ft_strmerger(2, get_value_by_key("PWD", env), "$ "); pwd = get_pwd(2);
if (pwd == NULL)
return (NULL);
prompt = ft_strmerger(2, pwd, "$ ");
free(pwd);
if (prompt == NULL) if (prompt == NULL)
{ {
ft_eprintf("minishell: malloc failed\n"); ft_eprintf("minishell: malloc failed\n");

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */ /* Created: 2023/02/14 13:45:30 by cchauvet #+# #+# */
/* Updated: 2023/02/21 15:39:18 by erey-bet ### ########.fr */ /* Updated: 2023/02/21 15:43:50 by erey-bet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

15
vsupp Normal file
View File

@ -0,0 +1,15 @@
{
readline
Memcheck:Leak
...
fun:readline
...
}
{
readline
Memcheck:Leak
...
fun:add_history
...
}