diff --git a/README.md b/README.md index 447225a..9f71c9a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,79 @@ # OS2021_Project1.Shell -OS2021_Project1.Shell \ No newline at end of file +### + +#### yeeshell.c + +main function and function definition + +#### yeeshell.h + +function declaration and macro definition + +### + +### 1. Deployment + +Pull from my shuishan git. + +```shell +git clone root@gitea.shuishan.net.cn:10195501441/OS2021_Project1.Shell.git +``` + +In the **MINIX3** environment, use clang to compile the program. + +```shell +clang yeeshell.c -o yeeshell +``` + +Run yeeshell. + +```shell +./yeeshell +``` + + + +### 2. Test Case + +​ (1) `cd /your/path` + +cd + +​ (2) `ls -a -l` + +ls + +​ (3) `ls -a -l > result.txt` + +redirect_out + +​ (4) `vi result.txt` + +vi + +​ (5) `grep a < result.txt` + +redirect_in + +​ (6) `ls -a -l | grep a ` + +pipe + +​ (7) `vi result.txt` + +​ This command can not be executed in the **MINIX3** environment. It prints the following error information. + +vi_bg + +​ (8) `mytop ` + +mytop + +​ (9) `history n` + +history + +​ (10) `exit` + +​ exit \ No newline at end of file diff --git a/lab_report/1 Shell.doc b/lab_report/1 Shell.doc new file mode 100644 index 0000000..1289c91 Binary files /dev/null and b/lab_report/1 Shell.doc differ diff --git a/project-1.pdf b/lab_report/project-1.pdf similarity index 100% rename from project-1.pdf rename to lab_report/project-1.pdf diff --git a/lab_report/structure.xmind b/lab_report/structure.xmind new file mode 100644 index 0000000..f7e444d Binary files /dev/null and b/lab_report/structure.xmind differ diff --git a/lab_report/test_case_img/cd.png b/lab_report/test_case_img/cd.png new file mode 100644 index 0000000..8e98ffc Binary files /dev/null and b/lab_report/test_case_img/cd.png differ diff --git a/lab_report/test_case_img/exit.png b/lab_report/test_case_img/exit.png new file mode 100644 index 0000000..b8bbe40 Binary files /dev/null and b/lab_report/test_case_img/exit.png differ diff --git a/lab_report/test_case_img/history.png b/lab_report/test_case_img/history.png new file mode 100644 index 0000000..65f4fe8 Binary files /dev/null and b/lab_report/test_case_img/history.png differ diff --git a/lab_report/test_case_img/ls.png b/lab_report/test_case_img/ls.png new file mode 100644 index 0000000..9b1d784 Binary files /dev/null and b/lab_report/test_case_img/ls.png differ diff --git a/lab_report/test_case_img/mytop.png b/lab_report/test_case_img/mytop.png new file mode 100644 index 0000000..502bbf1 Binary files /dev/null and b/lab_report/test_case_img/mytop.png differ diff --git a/lab_report/test_case_img/pipe.png b/lab_report/test_case_img/pipe.png new file mode 100644 index 0000000..3f6bffc Binary files /dev/null and b/lab_report/test_case_img/pipe.png differ diff --git a/lab_report/test_case_img/redirect_in.png b/lab_report/test_case_img/redirect_in.png new file mode 100644 index 0000000..ddc31b8 Binary files /dev/null and b/lab_report/test_case_img/redirect_in.png differ diff --git a/lab_report/test_case_img/redirect_out.png b/lab_report/test_case_img/redirect_out.png new file mode 100644 index 0000000..41fb4c5 Binary files /dev/null and b/lab_report/test_case_img/redirect_out.png differ diff --git a/lab_report/test_case_img/vi.png b/lab_report/test_case_img/vi.png new file mode 100644 index 0000000..b95dd9b Binary files /dev/null and b/lab_report/test_case_img/vi.png differ diff --git a/lab_report/test_case_img/vi_bg.png b/lab_report/test_case_img/vi_bg.png new file mode 100644 index 0000000..d317f3f Binary files /dev/null and b/lab_report/test_case_img/vi_bg.png differ diff --git a/lab_report/yeeshell.svg b/lab_report/yeeshell.svg new file mode 100644 index 0000000..cad6016 --- /dev/null +++ b/lab_report/yeeshell.svg @@ -0,0 +1,269 @@ +]>‎loop‎yeeshell‎读入命令行‎分析命令行‎获得参数数组‎前台或后台运行?‎执行命令‎有无管道?‎内建命令?‎exit‎cd‎history‎mytop‎重定向? \ No newline at end of file diff --git a/yeeshell.c b/yeeshell.c index 66aa94d..5674214 100644 --- a/yeeshell.c +++ b/yeeshell.c @@ -251,10 +251,10 @@ int do_pipe(char **pipe_arg_1, char **pipe_arg_2) } } - if ((prog_2 = fork()) == 0) /* Child process 1 */ + if ((prog_2 = fork()) == 0) /* Child process 2 */ { - - dup2(fds[0], 0); + close(0); + dup2(fds[0]); close(fds[0]); close(fds[1]);