From bdb1d443f59cd2ec0f2c49b581559e07abf35395 Mon Sep 17 00:00:00 2001 From: 10195501441 <10195501441@stu.ecnu.edu.com> Date: Tue, 16 Mar 2021 16:47:20 +0800 Subject: [PATCH] check_redirect adjustment --- yeeshell.c | 6 +++--- yeeshell.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/yeeshell.c b/yeeshell.c index 2abac20..8a1762a 100644 --- a/yeeshell.c +++ b/yeeshell.c @@ -157,10 +157,10 @@ int check_redirect(char **args, char *redirect_filename, char **redirect_args) if (redirect_flag == 1) /* redirect output */ { - strcpy(redirect_filename, rgs[i + 1]); + strcpy(redirect_filename, args[i + 1]); for (j = 0; j < i; j++) { - redirect_args[i] = args[i]; + strcpy(redirect_args[i], args[i]); } } 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) { - redirect_args[j++] = args[i]; + strcpy(redirect_args[j++], args[i]); } } return redirect_flag; diff --git a/yeeshell.h b/yeeshell.h index 08c1bef..38d76df 100644 --- a/yeeshell.h +++ b/yeeshell.h @@ -8,6 +8,8 @@ #define JOBS_MAX_QUANTITY 16 #define PATH_MAX_SIZE 256 #define LS_BUF_SIZE 1024 +#define REDIRECT_FILENAME_MAX_SIZE 64 /* redirection filename */ +#define REDIRECT_ARG_MAX_SIZE 16 /* redirection argument */ #define UNDF 0 /* undefined */ #define FG 1 /* running in foreground */