deux tours ont despawn dans les backrooms le 11 septembres
This commit is contained in:
commit
4c45a2c603
@ -6,7 +6,7 @@
|
||||
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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];
|
||||
|
||||
if (getcwd(path, sizeof(path)) != NULL)
|
||||
ft_putstr_fd(path, fd);
|
||||
ft_putendl_fd(path, fd);
|
||||
else
|
||||
{
|
||||
ft_putstr_fd("Error getcwd", fd);
|
||||
ft_putendl_fd("Error getcwd", fd);
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
@ -35,7 +35,7 @@ char *get_pwd(int fd)
|
||||
return (str);
|
||||
else
|
||||
{
|
||||
ft_putstr_fd("Error getcwd", fd);
|
||||
ft_putendl_fd("Error getcwd", fd);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
|
37
execution.c
37
execution.c
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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;
|
||||
size_t i;
|
||||
|
||||
if (executable_name == NULL)
|
||||
return (NULL);
|
||||
path = NULL;
|
||||
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)
|
||||
{
|
||||
/* if (ft_strcmp(cmd->executable, "pwd") == 0) */
|
||||
/* return (pwd(env, cmd->fd_out)); */
|
||||
if (ft_strcmp(cmd->executable, "env") == 0)
|
||||
return (print_env(env, cmd->fd_out));
|
||||
if (ft_strcmp(cmd->executable, "export") == 0)
|
||||
return (print_export(env, cmd->fd_out));
|
||||
/* if (ft_strcmp(cmd->executable, "cd") == 0) */
|
||||
/* return (move_folder(cmd->args[0], cmd->fd_out)); */
|
||||
int return_code;
|
||||
|
||||
return_code = -1;
|
||||
if (ft_strcmp(cmd->executable, "pwd") == 0)
|
||||
return_code = pwd(cmd->fd_out);
|
||||
else if (ft_strcmp(cmd->executable, "env") == 0)
|
||||
return_code = print_env(env, 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) */
|
||||
/* return (unset(env, cmd->args, cmd->fd_out)); */
|
||||
/* if (ft_strcmp(cmd->executable, "echo") == 0) */
|
||||
/* return (echo(cmd->fd_out, cmd->args[0])); */
|
||||
if (ft_strcmp(cmd->executable, "exit") == 0)
|
||||
return (-2);
|
||||
return (-1);
|
||||
/* return_code = (unset(env, cmd->args, cmd->fd_out)); */
|
||||
/* else if (ft_strcmp(cmd->executable, "echo") == 0) */
|
||||
/* return_code = (echo(cmd->fd_out, cmd->args + 1)); */
|
||||
else if (ft_strcmp(cmd->executable, "exit") == 0)
|
||||
return_code = -2;
|
||||
if (return_code != -1)
|
||||
cmd->executable = NULL;
|
||||
return (return_code);
|
||||
}
|
||||
|
||||
int ft_cmds_executor(t_list **cmds, t_list **env)
|
||||
|
9
main.c
9
main.c
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 *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)
|
||||
{
|
||||
ft_eprintf("minishell: malloc failed\n");
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user