diff --git a/Microshell/microshell b/Microshell/microshell index c736c9b..ac9c7d3 100755 Binary files a/Microshell/microshell and b/Microshell/microshell differ diff --git a/Microshell/microshell.c b/Microshell/microshell.c index 172ebb3..4862d93 100644 --- a/Microshell/microshell.c +++ b/Microshell/microshell.c @@ -76,8 +76,9 @@ void spathf (char **argv, int *spath){ *spath = l; } -void help (char **argv){ +void help (char **argv, char *dir){ if (fork() == 0){ + chdir(dir); execlp("less", "less", "help", NULL); perror("execlp"); exit(EXIT_FAILURE); @@ -261,18 +262,25 @@ void myps (char **argv){ } int main (){ - int spath = 1, i=0; + int spath = 1, i=0, b=0; using_history(); struct passwd *p = getpwuid(getuid()); while (1){ char *argv[100]; - char *komenda, *prompt, directory[max]; + char *komenda, *prompt, directory[max], bdir[max]; if (getcwd(directory, sizeof(directory)) == NULL){ perror("getcwd() error"); return -1; } + if (!b){ + if(getcwd(bdir, sizeof(bdir)) == NULL){ + perror("getcwd() error"); + return -1; + } + b=1; + } if (spath){ prompt = (char*)malloc(strlen(directory)+strlen(p->pw_name)+22 *sizeof(char)); @@ -313,7 +321,7 @@ int main (){ continue; } else if (!strcmp(argv[0], "help")){ - help(argv); + help(argv, bdir); continue; } else if (!strcmp(argv[0], "showtree")){