mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
exec: command to toggle execution
Execution starts out being enabled. But it can be toggled on and off by using the .exec command.
This commit is contained in:
parent
ac411d36cc
commit
6576c47b56
3 changed files with 13 additions and 4 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/19 18:03:11 by khais #+# #+# */
|
||||
/* Updated: 2025/04/09 13:59:20 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/09 14:03:39 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -45,6 +45,12 @@ static char *handle_special_command(char *line, t_minishell *app)
|
|||
ft_printf("[dbg: %d]\n", (int)app->debug);
|
||||
line[0] = '\0';
|
||||
}
|
||||
if (ft_strcmp(".exec", line) == 0)
|
||||
{
|
||||
app->exec = !app->exec;
|
||||
ft_printf("[exec: %d]\n", (int)app->exec);
|
||||
line[0] = '\0';
|
||||
}
|
||||
return (line);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,9 +33,10 @@
|
|||
*/
|
||||
static void execute_command(t_simple_cmd *cmd, t_minishell *app)
|
||||
{
|
||||
if (app->exec == false)
|
||||
return ;
|
||||
set_exec_mode_sig_handling();
|
||||
simple_cmd_execute(cmd, app);
|
||||
simple_cmd_destroy(cmd);
|
||||
set_interactive_mode_sig_handling();
|
||||
}
|
||||
|
||||
|
|
@ -71,6 +72,7 @@ static void app_init(t_minishell *app, char **envp)
|
|||
{
|
||||
ft_bzero(app, sizeof(t_minishell));
|
||||
app->env = env_from_envp(envp);
|
||||
app->exec = true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[], char **envp)
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/09 13:49:28 by khais #+# #+# */
|
||||
/* Updated: 2025/04/15 12:01:54 by khais ### ########.fr */
|
||||
/* Created: 2025/04/09 14:02:47 by khais #+# #+# */
|
||||
/* Updated: 2025/04/15 12:02:18 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -119,6 +119,7 @@ typedef struct s_minishell
|
|||
int lines_read;
|
||||
int last_return_value;
|
||||
bool debug;
|
||||
bool exec;
|
||||
} t_minishell;
|
||||
|
||||
t_redirect *t_redirect_add_back(t_redirect **init, t_redirect *back);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue