diff --git a/Microshell/help b/Microshell/help index 1391faa..67960f9 100644 --- a/Microshell/help +++ b/Microshell/help @@ -19,7 +19,18 @@ spath: help - shows help page 0 - turns off displaying current directory 1 - turns on displaying current directory -PATH commands +showtree: + help - shows help page + no argument - shows tree of current directory + one argument - shows tree of directory in argument +showps: + help - shows help page + prints all process names ond pids +mycp: + help - shows help page + with 2 arguments - copyies file from first argument to + file in second argument +PATH commands: if you want colors use for example ls --color diff --git a/Microshell/katalogz/plik1.txt b/Microshell/katalogz/plik1.txt deleted file mode 100644 index a832ddb..0000000 --- a/Microshell/katalogz/plik1.txt +++ /dev/null @@ -1,2 +0,0 @@ -To jest plik1.txt -jajajajaj diff --git a/Microshell/katalogz/test/test.txt b/Microshell/katalogz/test/test.txt deleted file mode 100644 index 1210b79..0000000 --- a/Microshell/katalogz/test/test.txt +++ /dev/null @@ -1 +0,0 @@ -testtt diff --git a/Microshell/microshell b/Microshell/microshell index 42429d0..5d8ddcf 100755 Binary files a/Microshell/microshell and b/Microshell/microshell differ diff --git a/Microshell/microshell.c b/Microshell/microshell.c index d04e3f1..ac2c38f 100644 --- a/Microshell/microshell.c +++ b/Microshell/microshell.c @@ -87,7 +87,7 @@ void help (char **argv){ void exe (char **argv){ if (fork() == 0){ execvp(argv[0], argv); - perror("execvp"); + perror("Comand execution error"); exit(EXIT_FAILURE); } else @@ -102,7 +102,7 @@ void ptab (int ile){ void tree (char **argv, char * directory){ if (argv[1] != NULL && argv[2] != NULL){ - printf("Too many arguments\nshowtree takes no arguments \nor exacly 1 argument for desired directory\n"); + printf("Too many arguments\n"); return; } else{ @@ -113,12 +113,16 @@ void tree (char **argv, char * directory){ int tab = 0; if (argv[1] != NULL && argv[2] == NULL){ /*jeden argument*/ + if (!strcmp(argv[1], "help")){ + printf("Showtree prints catalog and file structure\ntakes no arguments \nor exacly 1 argument for desired directory\n"); + exit(0); + } cd(argv); getcwd(ndr, sizeof(ndr)); } else strcpy(ndr, directory); - printf("Content of: %s\n", ndr); + printf("Content of: %s\n\n", ndr); if ((d = opendir(ndr)) != NULL){ /*wchodzimy do katalogu*/ while ((ent = readdir(d)) != NULL){ /*czytamy zawartosc*/ @@ -156,11 +160,16 @@ void tree (char **argv, char * directory){ void mycp (char **argv){ if (argv[1] == NULL || argv[2] == NULL){ - printf("Add arguments\n"); + if(argv[1] != NULL && argv[2] == NULL) + if (!strcmp(argv[1], "help")){ + printf("Needs exacly 2 arguments\ncopyies file from first argument to file in second argument\n"); + return; + } + printf("Add arguments\nfor more info type 'mycp help'\n"); return; } else if (argv[3] != NULL){ - printf("Too many arguments\n"); + printf("Too many arguments\nfor more info type 'mycp help'\n"); return; } else{ @@ -190,6 +199,14 @@ void mycp (char **argv){ } void myps (char **argv){ + if (argv[1] != NULL){ + if(!strcmp(argv[1], "help")){ + printf("Showps prints all prosess and pids\ntakes no arguments\n"); + } + else + printf("Type 'showps help'\n"); + return; + } if (fork() == 0){ if (chdir("/proc") != 0){ perror("cant open /proc");