diff --git a/Makefile b/Makefile index 2456888..c97bdba 100644 --- a/Makefile +++ b/Makefile @@ -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 -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} diff --git a/builtins/cd.c b/builtins/cd.c index 18ec289..649b6bf 100644 --- a/builtins/cd.c +++ b/builtins/cd.c @@ -6,21 +6,28 @@ /* 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" -int move_folder(char *path, int fd) +int move_folder(char **args, int fd) { 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 (chdir(path) == 0) return (0); - ft_printf("chdir error"); + write(2, "chdir error", 11); return (1); } else @@ -33,7 +40,7 @@ int move_folder(char *path, int fd) return (0); } free(join); - ft_printf("chdir error"); + write(2, "chdir error", 11); return (1); } }