When using cd it will change directory to home if not specifying directory
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <readline/readline.h>
|
#include <readline/readline.h>
|
||||||
#include <readline/history.h>
|
#include <readline/history.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
|
||||||
#define MAXCOM 1000 // max number of letters to be supported
|
#define MAXCOM 1000 // max number of letters to be supported
|
||||||
#define MAXLIST 100 // max number of commands to be supported
|
#define MAXLIST 100 // max number of commands to be supported
|
||||||
@@ -126,8 +127,14 @@ int ownCmdHandler(char** parsed)
|
|||||||
case 1:
|
case 1:
|
||||||
exit(0);
|
exit(0);
|
||||||
case 2:
|
case 2:
|
||||||
|
if(parsed[1]){
|
||||||
chdir(parsed[1]);
|
chdir(parsed[1]);
|
||||||
return 1;
|
return 1;
|
||||||
|
} else {
|
||||||
|
char *home = getenv("HOME");
|
||||||
|
chdir(home);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user