help error
This commit is contained in:
parent
4f18787256
commit
cec12d4163
Binary file not shown.
@ -76,8 +76,9 @@ void spathf (char **argv, int *spath){
|
|||||||
*spath = l;
|
*spath = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
void help (char **argv){
|
void help (char **argv, char *dir){
|
||||||
if (fork() == 0){
|
if (fork() == 0){
|
||||||
|
chdir(dir);
|
||||||
execlp("less", "less", "help", NULL);
|
execlp("less", "less", "help", NULL);
|
||||||
perror("execlp");
|
perror("execlp");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -261,18 +262,25 @@ void myps (char **argv){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main (){
|
int main (){
|
||||||
int spath = 1, i=0;
|
int spath = 1, i=0, b=0;
|
||||||
using_history();
|
using_history();
|
||||||
struct passwd *p = getpwuid(getuid());
|
struct passwd *p = getpwuid(getuid());
|
||||||
|
|
||||||
while (1){
|
while (1){
|
||||||
char *argv[100];
|
char *argv[100];
|
||||||
char *komenda, *prompt, directory[max];
|
char *komenda, *prompt, directory[max], bdir[max];
|
||||||
|
|
||||||
if (getcwd(directory, sizeof(directory)) == NULL){
|
if (getcwd(directory, sizeof(directory)) == NULL){
|
||||||
perror("getcwd() error");
|
perror("getcwd() error");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (!b){
|
||||||
|
if(getcwd(bdir, sizeof(bdir)) == NULL){
|
||||||
|
perror("getcwd() error");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
b=1;
|
||||||
|
}
|
||||||
|
|
||||||
if (spath){
|
if (spath){
|
||||||
prompt = (char*)malloc(strlen(directory)+strlen(p->pw_name)+22 *sizeof(char));
|
prompt = (char*)malloc(strlen(directory)+strlen(p->pw_name)+22 *sizeof(char));
|
||||||
@ -313,7 +321,7 @@ int main (){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[0], "help")){
|
else if (!strcmp(argv[0], "help")){
|
||||||
help(argv);
|
help(argv, bdir);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[0], "showtree")){
|
else if (!strcmp(argv[0], "showtree")){
|
||||||
|
Loading…
Reference in New Issue
Block a user