diff --git a/Microshell/microshell.c b/Microshell/microshell.c index 7316fac..3566488 100644 --- a/Microshell/microshell.c +++ b/Microshell/microshell.c @@ -7,7 +7,7 @@ const int max = 1000; -void cut(char **argv, char *command){ +int cut(char **argv, char *command){ int i = 0, w = 0, x = 0; char argument[100]; while (1){ @@ -32,11 +32,12 @@ void cut(char **argv, char *command){ w+=1; } } + return w+1; } int main (){ char* argv[100]; - int i; + int ile, i; while (1){ char komenda[max], directory[max]; if (getcwd(directory, sizeof(directory)) == NULL){ @@ -45,10 +46,8 @@ int main (){ } printf("[%s]$ ", directory); fgets(komenda, max, stdin); - cut(argv, komenda); - for(i=0; i<5; i++) - printf("%c ", argv[0][i]); - printf("\n"); + ile = cut(argv, komenda); + if (argv[0]==NULL) continue; else if (strcmp(argv[0], "exit") == 0) @@ -58,6 +57,9 @@ int main (){ execvp(argv[0], argv); else wait(NULL); + + for(i=0; i