msh/src/builtins/builtins.c

28 lines
555 B
C
Raw Normal View History

2026-01-19 15:03:36 -07:00
#include "builtins.h"
#include "../system/system.h"
#include "../util/util.h"
char hashes_calced = 0;
2026-01-19 15:03:36 -07:00
int cd_hash = 0;
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");
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;
}
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); };