mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
do postprocessing for each simple_cmd before execution
This commit is contained in:
parent
386d2bcb3a
commit
ba9751e089
2 changed files with 24 additions and 2 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/03/27 16:21:56 by khais #+# #+# */
|
/* Created: 2025/03/27 16:21:56 by khais #+# #+# */
|
||||||
/* Updated: 2025/04/04 19:56:34 by khais ### ########.fr */
|
/* Updated: 2025/04/07 17:56:56 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -21,6 +21,10 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "../../parser/remove_quotes/remove_quotes.h"
|
||||||
|
#include "../../postprocess/expansion/expand_vars.h"
|
||||||
|
#include "../../postprocess/fieldsplit/fieldsplit.h"
|
||||||
|
#include "../../postprocess/expansion/expand_wildcard.h"
|
||||||
|
|
||||||
static void command_not_found(t_simple_cmd *cmd)
|
static void command_not_found(t_simple_cmd *cmd)
|
||||||
{
|
{
|
||||||
|
|
@ -62,6 +66,22 @@ static t_simple_cmd *handle_redirections(t_simple_cmd *cmd, t_minishell *app)
|
||||||
return (cmd);
|
return (cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Do all the post-processing steps relating to a command.
|
||||||
|
*/
|
||||||
|
static t_simple_cmd *post_process_command(t_simple_cmd *cmd, t_minishell *app)
|
||||||
|
{
|
||||||
|
if (simple_cmd_expand_vars(cmd, app) == NULL)
|
||||||
|
return (simple_cmd_destroy(cmd), NULL);
|
||||||
|
if (simple_cmd_fieldsplit(cmd) == NULL)
|
||||||
|
return (simple_cmd_destroy(cmd), NULL);
|
||||||
|
if (simple_cmd_expand_wildcards(cmd) == NULL)
|
||||||
|
return (simple_cmd_destroy(cmd), NULL);
|
||||||
|
if (simple_cmd_remove_quotes(cmd) == NULL)
|
||||||
|
return (simple_cmd_destroy(cmd), NULL);
|
||||||
|
return (cmd);
|
||||||
|
}
|
||||||
|
|
||||||
void simple_cmd_execute(t_simple_cmd *cmd, t_minishell *app)
|
void simple_cmd_execute(t_simple_cmd *cmd, t_minishell *app)
|
||||||
{
|
{
|
||||||
char *exe;
|
char *exe;
|
||||||
|
|
@ -69,6 +89,8 @@ void simple_cmd_execute(t_simple_cmd *cmd, t_minishell *app)
|
||||||
|
|
||||||
if (cmd == NULL || cmd->words == NULL || cmd->words->word == NULL)
|
if (cmd == NULL || cmd->words == NULL || cmd->words->word == NULL)
|
||||||
return ;
|
return ;
|
||||||
|
if (post_process_command(cmd, app) == NULL)
|
||||||
|
return ;
|
||||||
if (handle_redirections(cmd, app) == NULL)
|
if (handle_redirections(cmd, app) == NULL)
|
||||||
return ;
|
return ;
|
||||||
if (execute_builtin(cmd, app) != BUILTIN_INVALID)
|
if (execute_builtin(cmd, app) != BUILTIN_INVALID)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/06 13:44:06 by kcolin #+# #+# */
|
/* Created: 2025/02/06 13:44:06 by kcolin #+# #+# */
|
||||||
/* Updated: 2025/04/15 11:53:49 by khais ### ########.fr */
|
/* Updated: 2025/04/15 11:54:46 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue