소스 검색

check_redirect completed

master
10195501441 3 년 전
부모
커밋
275a71c9e6
3개의 변경된 파일14개의 추가작업 그리고 13개의 파일을 삭제
  1. +10
    -0
      result.txt
  2. BIN
      yeeshell
  3. +4
    -13
      yeeshell.c

+ 10
- 0
result.txt 파일 보기

@ -0,0 +1,10 @@
total 52
drwxr-xr-x 4 root root 120 Mar 16 22:47 .
dr-xr-x---. 14 root root 4096 Mar 16 15:20 ..
drwxr-xr-x 8 root root 201 Mar 16 22:04 .git
-rw-r--r-- 1 root root 46 Mar 10 17:40 README.md
-rwx------ 1 root root 0 Mar 16 22:47 result.txt
drwxr-xr-x 2 root root 64 Mar 16 11:27 .vscode
-rwxr-xr-x 1 root root 23728 Mar 16 22:46 yeeshell
-rw-r--r-- 1 root root 13535 Mar 16 22:46 yeeshell.c
-rw-r--r-- 1 root root 3914 Mar 16 22:44 yeeshell.h

BIN
yeeshell 파일 보기


+ 4
- 13
yeeshell.c 파일 보기

@ -156,7 +156,7 @@ int check_redirect(char **args, char *redirect_filename, char **redirect_args)
i++; i++;
} }
if (redirect_flag == 1) /* redirect output */ if ((redirect_flag == 1) || (redirect_flag == 2))
{ {
strcpy(redirect_filename, args[i + 1]); strcpy(redirect_filename, args[i + 1]);
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
@ -164,15 +164,7 @@ int check_redirect(char **args, char *redirect_filename, char **redirect_args)
redirect_args[j] = args[j]; redirect_args[j] = args[j];
} }
} }
else if (redirect_flag == 2) /* redirect input */
{
redirect_filename = args[0];
i++;
while (args[i] != NULL)
{
redirect_args[j++] = args[i++];
}
}
return redirect_flag; return redirect_flag;
} }
@ -181,16 +173,15 @@ int execute(char *cmdline, char **args)
int bg = 0, i = 0, redirect_flag = 0, fd = 1; int bg = 0, i = 0, redirect_flag = 0, fd = 1;
pid_t pid; pid_t pid;
char *redirect_filename = NULL; char *redirect_filename = NULL;
redirect_filename = (char *)calloc(32, sizeof(char)); redirect_filename = (char *)calloc(REDIRECT_FILENAME_MAX_SIZE, sizeof(char));
char *redirect_args[ARGS_MAX_QUANTITY]; char *redirect_args[ARGS_MAX_QUANTITY];
memset(redirect_args, NULL, sizeof(redirect_args));
sigset_t mask_all, mask_prev; sigset_t mask_all, mask_prev;
sigprocmask(SIG_BLOCK, NULL, &mask_all); sigprocmask(SIG_BLOCK, NULL, &mask_all);
sigaddset(&mask_all, SIGCHLD); sigaddset(&mask_all, SIGCHLD);
bg = parseline(cmdline, args); bg = parseline(cmdline, args);
redirect_flag = check_redirect(args, redirect_filename, redirect_args); redirect_flag = check_redirect(args, redirect_filename, redirect_args);
printf("%s %s %s %s", redirect_args[0], redirect_args[1], redirect_args[2], redirect_filename);
if (args[0] == NULL) if (args[0] == NULL)
{ {
return 1; return 1;

||||||
x
 
000:0
불러오는 중...
취소
저장