Browse Source

Ignore les commandes pipe alors qu'une redirection sortie est faite

Loquicom 6 years ago
parent
commit
b6a0988e86
2 changed files with 21 additions and 1 deletions
  1. 11 1
      mysh.c
  2. 10 0
      test

+ 11 - 1
mysh.c

@@ -216,12 +216,22 @@ int run(CommandTab ct){
     int tube[ct.length][2];
     int tubepos = 0;
     int infd = -1, outfd = -1, errfd = -1;
-    boolean bpipe = false;
+    boolean bpipe = false, nextpipe = false;
     //Parcours les commandes
     for(int i = 0; i < ct.length; i++){
         c = ct.cmd[i];
         printf("Cmd : %s\n", c->name);
+        //Si pipe avant
+        if(nextpipe){
+            //Si fin chaine pipe
+            if(c->next != SHELL_PIPE){
+                nextpipe = false;
+            }
+            //Passe la commande
+            continue;
+        }
         //Si pipe creation d'un fichier commun
+        nextpipe = c->next == SHELL_PIPE ;
         if(c->next == SHELL_PIPE && c->output == STDOUT){
             bpipe = true;
             //Creation tube

+ 10 - 0
test

@@ -0,0 +1,10 @@
+command.c
+error.c
+execute.c
+mysh.c
+parser.c
+str.c
+wildcard.c
+0
+card.c
+0