diff --git a/Microshell/microshell b/Microshell/microshell index 5d8ddcf..c736c9b 100755 Binary files a/Microshell/microshell and b/Microshell/microshell differ diff --git a/Microshell/microshell.c b/Microshell/microshell.c index ac2c38f..172ebb3 100644 --- a/Microshell/microshell.c +++ b/Microshell/microshell.c @@ -35,19 +35,21 @@ void rmChar(char *str, char garbage) { /*przesledzic jak to dziala!!!!! w opis *dst = '\0'; } -void cd (char **argv){ +int cd (char **argv){ if(argv[1] == NULL){ printf("Add arguments\n"); - return; + return -1; } else if(argv[2] != NULL){ printf("Too many arguments\n"); - return; + return -1; } else{ - if (chdir(argv[1]) != 0) + if (chdir(argv[1]) != 0){ perror("chdir error"); - return; + return -1; + } + return 0; } } @@ -117,7 +119,8 @@ void tree (char **argv, char * directory){ printf("Showtree prints catalog and file structure\ntakes no arguments \nor exacly 1 argument for desired directory\n"); exit(0); } - cd(argv); + if(cd(argv) == -1) + exit(0); getcwd(ndr, sizeof(ndr)); } else