Merge branch 'master' of git.chauvet.pro:starnakin/minishell

This commit is contained in:
Camille Chauvet 2023-02-28 13:20:25 +01:00
commit 9a5cca3e2d
2 changed files with 12 additions and 5 deletions

View File

@ -1,5 +1,5 @@
UTILS_SRC = utils/ft_is_in_quote.c utils/ft_strncpy.c utils/ft_strreplace.c utils/ft_strnchr.c utils/ft_split_quoted.c utils/ft_strshift.c utils/ft_quote_remover.c utils/ft_str_is_empty.c utils/ft_atoi_check.c UTILS_SRC = utils/ft_is_in_quote.c utils/ft_strncpy.c utils/ft_strreplace.c utils/ft_strnchr.c utils/ft_split_quoted.c utils/ft_strshift.c utils/ft_quote_remover.c utils/ft_str_is_empty.c utils/ft_atoi_check.c
SRCS = ${UTILS_SRC} main.c file.c infile.c outfile.c heredoc.c syntatics.c cmd.c cmds.c env.c env2.c env3.c execution.c spacer.c env_fill.c builtins/echo.c builtins/pwd.c builtins/export.c builtins/env.c builtins/cd.c builtins/exit.c SRCS = ${UTILS_SRC} main.c file.c infile.c outfile.c heredoc.c syntatics.c cmd.c cmds.c env.c env2.c env3.c execution.c spacer.c env_fill.c builtins/echo.c builtins/pwd.c builtins/export.c builtins/env.c builtins/cd.c builtins/exit.c builtins/unset.c
OBJS = ${SRCS:.c=.o} OBJS = ${SRCS:.c=.o}

View File

@ -6,21 +6,28 @@
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */ /* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/20 14:27:36 by erey-bet #+# #+# */ /* Created: 2023/02/20 14:27:36 by erey-bet #+# #+# */
/* Updated: 2023/02/21 14:41:58 by erey-bet ### ########.fr */ /* Updated: 2023/02/28 13:13:23 by erey-bet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../minishell.h" #include "../minishell.h"
int move_folder(char *path, int fd) int move_folder(char **args, int fd)
{ {
char *join; char *join;
char *path;
if (args[1] != NULL)
{
write(2, "cd: too many argument", 22);
return (1);
}
path = args[0];
if (path[0] == '/' || ft_strncmp(path, "..", ft_strlen(path)) == 0) if (path[0] == '/' || ft_strncmp(path, "..", ft_strlen(path)) == 0)
{ {
if (chdir(path) == 0) if (chdir(path) == 0)
return (0); return (0);
ft_printf("chdir error"); write(2, "chdir error", 11);
return (1); return (1);
} }
else else
@ -33,7 +40,7 @@ int move_folder(char *path, int fd)
return (0); return (0);
} }
free(join); free(join);
ft_printf("chdir error"); write(2, "chdir error", 11);
return (1); return (1);
} }
} }