|
@@ -15,10 +15,12 @@
|
|
|
|
|
|
/* --- Extern --- */
|
|
|
extern Error error;
|
|
|
-char* cmdlist[2] = {
|
|
|
+char* cmdlist[3] = {
|
|
|
"cd",
|
|
|
+ "exit",
|
|
|
NULL
|
|
|
};
|
|
|
+boolean exitsh = false;
|
|
|
|
|
|
/* --- Fonctions publiques --- */
|
|
|
void ini_pid_list(pid_list* pl) {
|
|
@@ -92,7 +94,8 @@ void clean_pid(pid_list* pl) {
|
|
|
boolean is_internal_cmd(const char* cmd) {
|
|
|
//Parcours tableau pour trouver correspondance
|
|
|
for (int i = 0; cmdlist[i] != NULL; i++) {
|
|
|
- if (strncmp(cmd, cmdlist[i], strlen(cmdlist[i]) + 1) == 0) {
|
|
|
+ printf("%s - %s | %ld\n", cmd, cmdlist[i], strlen(cmd));
|
|
|
+ if (strncmp(cmd, cmdlist[i], strlen(cmd)) == 0) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -105,7 +108,13 @@ int launch_internal_command(Command* cmd) {
|
|
|
if (strncmp(cmd->name, cmdlist[0], length) == 0) {
|
|
|
result = cd(cmd->argc, cmd->argv);
|
|
|
return result;
|
|
|
- } //Aucune commande
|
|
|
+ }
|
|
|
+ //exit
|
|
|
+ else if (strncmp(cmd->name, cmdlist[1], length) == 0) {
|
|
|
+ result = exit_sh(cmd->argc, cmd->argv);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ //Aucune commande
|
|
|
else {
|
|
|
return SHELL_FAIL;
|
|
|
}
|
|
@@ -135,4 +144,9 @@ int cd(int argc, char** argv) {
|
|
|
}
|
|
|
return EXIT_SUCCESS;
|
|
|
//show_current_dir("current working directory is: ", "\n");
|
|
|
+}
|
|
|
+
|
|
|
+int exit_sh(int argc, char** argv){
|
|
|
+ exitsh = true;
|
|
|
+ return EXIT_SUCCESS;
|
|
|
}
|