Browse Source

:bug: Correction presence char indésirable

Loquicom 6 years ago
parent
commit
6f207d9d59
2 changed files with 3 additions and 6 deletions
  1. 1 4
      mysh.c
  2. 2 2
      str.c

+ 1 - 4
mysh.c

@@ -161,7 +161,7 @@ int main(int argc, char* argv[]) {
             continue;
         }
         //Si aucune commande on passe
-        printf("%d\n", ct.length);
+        printf("Nb cmd : %d\n", ct.length);
         if(ct.length == 0){
             clean_command(&ct);
             continue;
@@ -220,7 +220,6 @@ int run(CommandTab ct){
     //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
@@ -273,7 +272,6 @@ int run(CommandTab ct){
         } else {
             result = exec_shell(c->name, c->argv);
         }
-        printf("%d\n", result);
         //Reset IO
         if(c->input != STDIN){
             infd = redirect_fd(STDIN, infd);
@@ -294,7 +292,6 @@ int run(CommandTab ct){
             }
         }
         //Fermeture tube
-        printf("B %d\n", bpipe);
         if(bpipe){
             bpipe = false;
             if(close(outfd) == ERR){

+ 2 - 2
str.c

@@ -27,8 +27,8 @@ char* ltrim(char* str, char mask){
     }
     //Sinon creation nouvelle chaine
     res = malloc(sizeof(char) * (strlen(str) - cmpt + 1));
-    memset(res, 0, cmpt + 1);
-    for(int i = 0, j = cmpt; i < (strlen(str) - cmpt); i++, j++){
+    memset(res, 0, strlen(str) - cmpt + 1);
+    for(int i = 0, j = cmpt; j < (strlen(str)); i++, j++){
         res[i] = str[j];
     }
     //Retour nouvelle chaine