path and cd builtin
This commit is contained in:
parent
294261bdc7
commit
2a3679b272
16 changed files with 814 additions and 44 deletions
22
src/builtins/builtins.c
Normal file
22
src/builtins/builtins.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include "builtins.h"
|
||||
#include "../system/system.h"
|
||||
#include "../util/util.h"
|
||||
|
||||
int hashes_calced = 0;
|
||||
int cd_hash = 0;
|
||||
|
||||
int msh_try_builtin(char *cmd, char **args) {
|
||||
int hash = str_hash(cmd);
|
||||
|
||||
if (hashes_calced == 0) {
|
||||
cd_hash = str_hash("cd");
|
||||
hashes_calced = 1;
|
||||
}
|
||||
if (hash == cd_hash) {
|
||||
msh_builtin_cd(args[1]);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
void msh_builtin_cd(char *ch) { msh_set_working_directory(ch); };
|
||||
Loading…
Add table
Add a link
Reference in a new issue