diff --git a/src/boitoutil/essential_shell.c b/src/boitoutil/essential_shell.c
new file mode 100644
index 0000000..d54db62
--- /dev/null
+++ b/src/boitoutil/essential_shell.c
@@ -0,0 +1,41 @@
+/**
+ * @file essential_shell.c
+ * @author rick <rick@gnous.eu>
+ * @date 2021
+ */
+
+#include "essential_shell.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/**
+ * error(): gère les erreurs selon leur code et leur type
+ * @code: code de l’erreur, voir les différents codes plus bas
+ * @type: NON_FATAL_ERROR pour continuer l’exécution
+ *        FATAL_ERROR pour stoper le programme 
+ * @message: message à afficher pour + d’infos ou erreur non implémentée
+ *
+ * 1  erreur lors de la création des pipes
+ */
+void error(int code, int type, char *message) 
+{
+  switch (code)
+  {
+    case 1:
+      printf("Erreur lors de la création des pipes.\n");
+      break;
+
+    default:
+      if (message == NULL)
+        printf("Erreur inconnue.\n");
+      else
+        printf("%s\n", message);
+  }
+
+  if (message != NULL)
+    printf("Message complémentaire :\n%s\n", message);
+
+  if (type == FATAL_ERROR)
+    exit(code);
+}
diff --git a/src/boitoutil/essential_shell.h b/src/boitoutil/essential_shell.h
new file mode 100644
index 0000000..2c088ca
--- /dev/null
+++ b/src/boitoutil/essential_shell.h
@@ -0,0 +1,19 @@
+/**
+ * Header pour la bibliothèque permettant d’avoir des 
+ * outils essentiels pour le shell tel que la fonction pour 
+ * afficher des erreurs.
+ * @file essential_shell.h
+ * @author rick <rick@gnous.eu>
+ * @date 2021
+ */
+
+#ifndef _ESSHELL_
+#   define _ESSHELL_
+
+#define SHELL rishtik
+#define FATAL_ERROR 1
+#define NON_FATAL_ERROR 0
+
+void error(int code, int type, char *message);
+
+#endif
diff --git a/src/boitoutil/parser.h b/src/boitoutil/parser.h
index b86e4ff..ee43927 100644
--- a/src/boitoutil/parser.h
+++ b/src/boitoutil/parser.h
@@ -11,7 +11,6 @@
 #   define _PARSER_H_
 
 #define MAX_LENGTH 200 /* taille maximum des tableaux utilisés */
-#define SHELL rishtik
 
 char* get_input();
 void get_command(char *args[], char find);
diff --git a/src/shellOpt.c b/src/shellOpt.c
index 5f257d7..01225a4 100644
--- a/src/shellOpt.c
+++ b/src/shellOpt.c
@@ -5,6 +5,7 @@
  */
 
 #include "parser.h"
+#include "essential_shell.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -14,93 +15,78 @@
 
 int main()
 {
-  int pid;
-  char *args[MAX_LENGTH];
-  char *command[MAX_LENGTH];
+  /** commands contient l’entrée utilisateur parsée avec | :
+   *  ls | wc -l -> [ls, wc -l]
+   *
+   *  args contient une commande à la fois avec ses arguments séparés
+   *  par les espaces : 
+   *  ls -R test -> [ls, -R, test]
+   */
+  char *commands[MAX_LENGTH]; 
+  char *args[MAX_LENGTH]; 
+
+  int pid, index = 0, end = 0; /* end permet de savoir quand s’arreter */
   int my_pipe[2];
+
   if (pipe(my_pipe) == -1)
-  {
-    printf("erreur pipe");
-    return 1;
-  }
+    error(1, FATAL_ERROR, NULL);
+
   for (int i = 0; i < MAX_LENGTH; i++)
   {
     args[i] = (char *) calloc(MAX_LENGTH, sizeof(char));
-    command[i] = (char *) calloc(MAX_LENGTH, sizeof(char));
+    commands[i] = (char *) calloc(MAX_LENGTH, sizeof(char));
   }
 
-  get_command(args, '|');
+  get_command(commands, '|');
 
-  int index = 0;
-  while (strcmp(args[0], "exit"))
+  while (strcmp(commands[0], "exit"))
   {
-    while (args[index] != NULL)
+    while (commands[index] != NULL)
     {
-      if (strncmp(args[index], "cd", 2))
-      {
         pid = fork();
         if (!pid)
         {
-          parse_string(args[index], command, ' ');
-          if (args[1] != NULL) 
-          {
-            if (args[index+1] == NULL)
-              dup2(my_pipe[0], STDIN_FILENO);
-            else if (index == 0)
-              dup2(my_pipe[1], STDOUT_FILENO);
-            /*else {
-              dup2(my_pipe[0], STDIN_FILENO);
-              dup2(my_pipe[1], STDOUT_FILENO);
-            }*/
-            close(my_pipe[0]);
-            close(my_pipe[1]);
-          }
+          parse_string(commands[index], args, ' ');
+          if (commands[index+1] == NULL)
+            dup2(my_pipe[0], STDIN_FILENO);
+          else if (index == 0)
+            dup2(my_pipe[1], STDOUT_FILENO);
+          close(my_pipe[0]);
+          close(my_pipe[1]);
 
-          execvp(command[0], command);
+          execvp(args[0], args);
           return 0;
         }
         else 
         {
-          if (args[index + 1] == NULL)
+          if (commands[index + 1] == NULL)
           {
             close(my_pipe[1]);
             close(my_pipe[0]);
             waitpid(pid, NULL, 0);
           }
         }
-      }
-      else
-      {
-        parse_string(args[index], command, ' ');
-        execvp(command[0], command);
-        for (int i = 0; i < MAX_LENGTH; i++)
-        {
-          free(command[i]);
-          command[i] = (char *) calloc(MAX_LENGTH, sizeof(char));
-        }
-      }
       index++;
     }
 
+    /* remise à 0 des entrées, des commandes, des pipes et de l’index */
     for (int i = 0; i < MAX_LENGTH; i++)
     {
       free(args[i]);
-      free(command[i]);
+      free(commands[i]);
       args[i] = (char *) calloc(MAX_LENGTH, sizeof(char));
-      command[i] = (char *) calloc(MAX_LENGTH, sizeof(char));
+      commands[i] = (char *) calloc(MAX_LENGTH, sizeof(char));
     }
-    get_command(args, '|');
+
+    get_command(commands, '|');
     if (pipe(my_pipe) == -1)
-    {
-      printf("erreur sur le pipe");
-      return 1;
-    }
+      error(1, FATAL_ERROR, NULL);
     index = 0;
   }
 
   for (int i = 0; i < MAX_LENGTH; i++)
   {
-    free(command[i]);
+    free(commands[i]);
     free(args[i]);
   }
   return 0;