You can add 2 args on the command line
This commit is contained in:
		
							parent
							
								
									3c402d4be4
								
							
						
					
					
						commit
						b370a6aec6
					
				
					 1 changed files with 11 additions and 2 deletions
				
			
		
							
								
								
									
										13
									
								
								mini_shell.c
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								mini_shell.c
									
										
									
									
									
								
							| 
						 | 
					@ -82,7 +82,7 @@ void execution(char *arg1, char *arg2, char *arg3, char **env)
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					close(0); dup(fd0); // Redirection de l'entrée standard
 | 
										close(0); dup(fd0); // Redirection de l'entrée standard
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				if(strcmp(arg2, ">") == 0) // On redirige la sortie vers un fichier (arg3)
 | 
									else if(strcmp(arg2, ">") == 0) // On redirige la sortie vers un fichier (arg3)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					if((fd1 = open(arg3, O_WRONLY | O_CREAT | O_TRUNC , 0666)) == -1)
 | 
										if((fd1 = open(arg3, O_WRONLY | O_CREAT | O_TRUNC , 0666)) == -1)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
| 
						 | 
					@ -91,7 +91,7 @@ void execution(char *arg1, char *arg2, char *arg3, char **env)
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					close(1); dup(fd1); // Redirection de la sortie standard
 | 
										close(1); dup(fd1); // Redirection de la sortie standard
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				if(strcmp(arg2, "&") == 0) // Exécution en arrière plan, on a rien en entrée
 | 
									else if(strcmp(arg2, "&") == 0) // Exécution en arrière plan, on a rien en entrée
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					if((fd0 = open("/dev/null", O_RDONLY)) == -1)
 | 
										if((fd0 = open("/dev/null", O_RDONLY)) == -1)
 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
| 
						 | 
					@ -100,6 +100,15 @@ void execution(char *arg1, char *arg2, char *arg3, char **env)
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					close(0); dup(fd0);
 | 
										close(0); dup(fd0);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
									else // Exécution simple (avec arguments)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										free(options);
 | 
				
			||||||
 | 
										options = malloc(4 * sizeof(char *));
 | 
				
			||||||
 | 
										options[0] = arg1;
 | 
				
			||||||
 | 
										options[1] = arg2;
 | 
				
			||||||
 | 
										options[2] = arg3;
 | 
				
			||||||
 | 
										options[3] = NULL;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
				execvpe(arg1, options, env);
 | 
									execvpe(arg1, options, env);
 | 
				
			||||||
				erreur("execvpe n'a pas fonctionné");
 | 
									erreur("execvpe n'a pas fonctionné");
 | 
				
			||||||
				exit(EXIT_FAILURE);
 | 
									exit(EXIT_FAILURE);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue