From 13adb34b7dfdf6762193ef2ce327aaf36e25186d Mon Sep 17 00:00:00 2001 From: 10195501441 <10195501441@stu.ecnu.edu.com> Date: Tue, 16 Mar 2021 16:55:00 +0800 Subject: [PATCH] check_redirect adjustment --- yeeshell.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yeeshell.c b/yeeshell.c index 8a1762a..1925923 100644 --- a/yeeshell.c +++ b/yeeshell.c @@ -160,7 +160,7 @@ int check_redirect(char **args, char *redirect_filename, char **redirect_args) strcpy(redirect_filename, args[i + 1]); for (j = 0; j < i; j++) { - strcpy(redirect_args[i], args[i]); + redirect_args[j] = args[j]; } } else if (redirect_flag == 2) /* redirect input */ @@ -169,7 +169,7 @@ int check_redirect(char **args, char *redirect_filename, char **redirect_args) i++; while (args[i] != NULL) { - strcpy(redirect_args[j++], args[i]); + redirect_args[j++] = args[i++]); } } return redirect_flag; @@ -187,7 +187,7 @@ int execute(char *cmdline, char **args) sigaddset(&mask_all, SIGCHLD); bg = parseline(cmdline, args); redirect_flag = check_redirect(args, redirect_filename, redirect_args); - printf("%d %s %s\n", redirect_flag, redirect_filename, redirect_args); + printf("%d %s %s %s %s\n", redirect_flag, redirect_filename, redirect_args[0], redirect_args[1], redirect_args[2]); if (args[0] == NULL) {