|
@@ -11,6 +11,7 @@
|
|
|
#include "error.h"
|
|
|
#include "str.h"
|
|
|
#include "parser.h"
|
|
|
+#include "command.h"
|
|
|
#include "mysh.h"
|
|
|
|
|
|
#include <sys/types.h>
|
|
@@ -50,7 +51,7 @@ int main(int argc, char* argv[]) {
|
|
|
char str[BUFFER_SIZE];
|
|
|
int a;
|
|
|
//Initialisation erreur
|
|
|
- error_finit("mysh.log");
|
|
|
+ error_finit("mysh.log");
|
|
|
//Recup ligne
|
|
|
//printf("%s\n", fgets(str, 500, stdin));&
|
|
|
memset(str, 0, 500);
|
|
@@ -76,29 +77,14 @@ int main(int argc, char* argv[]) {
|
|
|
printf(" Argument %d : %s\n", j, c->argv[j]);
|
|
|
}
|
|
|
printf("Commande en fond : %d\n\n", ct.bck);
|
|
|
+ //Si c'est une commande interne on l'execute
|
|
|
+ if(is_internal_cmd(ct.cmd[i]->name)){
|
|
|
+ show_current_dir(NULL, "\n");
|
|
|
+ printf("Result : %d\n", launch_internal_command(ct.cmd[i]));
|
|
|
+ show_current_dir(NULL, "\n");
|
|
|
+ }
|
|
|
}
|
|
|
//Supprime
|
|
|
clean_command(&ct);
|
|
|
error.exit();
|
|
|
-}
|
|
|
-
|
|
|
-/* --- Commandes internes --- */
|
|
|
-void cd(int argc, char** argv) {
|
|
|
- //Si trop d'arguments
|
|
|
- if (argc > 2) {
|
|
|
- error.print("too many arguments : 1 required, %d given\n", argc - 1);
|
|
|
- } else {
|
|
|
- //Si aucun argument on va à la racine
|
|
|
- if (argc == 1) {
|
|
|
- if (chdir("/") == ERR) {
|
|
|
- addperror("Erreur chdir()");
|
|
|
- }
|
|
|
- } //Sinon on va dans le dossier indiqué par l'utilisateur
|
|
|
- else {
|
|
|
- if (chdir(argv[1]) == ERR) {
|
|
|
- error.print("path does not exist\n");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //show_current_dir("current working directory is: ", "\n");
|
|
|
}
|