From 6bb727c31d6f4f9a952b7f8bd97dd96d36edaf92 Mon Sep 17 00:00:00 2001 From: 10195501441 <10195501441@stu.ecnu.edu.com> Date: Tue, 16 Mar 2021 16:31:53 +0800 Subject: [PATCH] check_redirect adjustment --- yeeshell.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/yeeshell.c b/yeeshell.c index c0b45cb..2abac20 100644 --- a/yeeshell.c +++ b/yeeshell.c @@ -157,7 +157,7 @@ int check_redirect(char **args, char *redirect_filename, char **redirect_args) if (redirect_flag == 1) /* redirect output */ { - redirect_filename = args[i + 1]; + strcpy(redirect_filename, rgs[i + 1]); for (j = 0; j < i; j++) { redirect_args[i] = args[i]; @@ -179,7 +179,8 @@ int execute(char *cmdline, char **args) { int bg = 0, i = 0, redirect_flag = 0; pid_t pid; - char *redirect_filename; + char *redirect_filename = NULL; + redirect_filename = (char *)calloc(32, sizeof(char)); char *redirect_args[ARGS_MAX_QUANTITY]; sigset_t mask_all, mask_prev; sigprocmask(SIG_BLOCK, NULL, &mask_all);