2026-01-19 15:03:36 -07:00
|
|
|
#include "builtins.h"
|
|
|
|
|
#include "../system/system.h"
|
|
|
|
|
#include "../util/util.h"
|
|
|
|
|
|
|
|
|
|
int hashes_calced = 0;
|
|
|
|
|
int cd_hash = 0;
|
2026-01-20 17:09:58 -07:00
|
|
|
int exit_hash = 0;
|
2026-01-19 15:03:36 -07:00
|
|
|
|
|
|
|
|
int msh_try_builtin(char *cmd, char **args) {
|
|
|
|
|
int hash = str_hash(cmd);
|
|
|
|
|
|
|
|
|
|
if (hashes_calced == 0) {
|
|
|
|
|
cd_hash = str_hash("cd");
|
2026-01-20 17:09:58 -07:00
|
|
|
exit_hash = str_hash("exit");
|
2026-01-19 15:03:36 -07:00
|
|
|
hashes_calced = 1;
|
|
|
|
|
}
|
|
|
|
|
if (hash == cd_hash) {
|
|
|
|
|
msh_builtin_cd(args[1]);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2026-01-20 17:09:58 -07:00
|
|
|
if (hash == exit_hash) {
|
|
|
|
|
msh_exit_shell();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2026-01-19 15:03:36 -07:00
|
|
|
return 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void msh_builtin_cd(char *ch) { msh_set_working_directory(ch); };
|