mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
debug: show command about to be executed in debug mode
This commit is contained in:
parent
204ed35ff4
commit
81febcfcdd
8 changed files with 65 additions and 3 deletions
1
Makefile
1
Makefile
|
|
@ -47,6 +47,7 @@ srcs = \
|
|||
src/executing/simple_cmd/builtins.c \
|
||||
src/executing/simple_cmd/builtin_unset.c \
|
||||
src/executing/simple_cmd/simple_cmd_execute.c \
|
||||
src/executing/simple_cmd/simple_cmd_execute_debug.c \
|
||||
src/executing/simple_cmd/subprocess.c \
|
||||
src/ft_errno.c \
|
||||
src/get_command.c \
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/27 16:21:56 by khais #+# #+# */
|
||||
/* Updated: 2025/04/07 17:56:56 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/08 16:12:36 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -25,6 +25,7 @@
|
|||
#include "../../postprocess/expansion/expand_vars.h"
|
||||
#include "../../postprocess/fieldsplit/fieldsplit.h"
|
||||
#include "../../postprocess/expansion/expand_wildcard.h"
|
||||
#include "simple_cmd_execute_debug.h"
|
||||
|
||||
static void command_not_found(t_simple_cmd *cmd)
|
||||
{
|
||||
|
|
@ -91,6 +92,7 @@ void simple_cmd_execute(t_simple_cmd *cmd, t_minishell *app)
|
|||
return ;
|
||||
if (post_process_command(cmd, app) == NULL)
|
||||
return ;
|
||||
simple_cmd_execute_debug(cmd, app);
|
||||
if (handle_redirections(cmd, app) == NULL)
|
||||
return ;
|
||||
if (execute_builtin(cmd, app) != BUILTIN_INVALID)
|
||||
|
|
|
|||
24
src/executing/simple_cmd/simple_cmd_execute_debug.c
Normal file
24
src/executing/simple_cmd/simple_cmd_execute_debug.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* simple_cmd_execute_debug.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/10 15:36:26 by khais #+# #+# */
|
||||
/* Updated: 2025/04/10 15:37:29 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "simple_cmd_execute_debug.h"
|
||||
#include "libft.h"
|
||||
#include "../../parser/simple_cmd/simple_cmd.h"
|
||||
|
||||
void simple_cmd_execute_debug(t_simple_cmd *cmd, t_minishell *app)
|
||||
{
|
||||
if (app->debug)
|
||||
{
|
||||
ft_printf("about to execute\n");
|
||||
simple_cmd_root_debug(cmd);
|
||||
}
|
||||
}
|
||||
20
src/executing/simple_cmd/simple_cmd_execute_debug.h
Normal file
20
src/executing/simple_cmd/simple_cmd_execute_debug.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* simple_cmd_execute_debug.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/10 15:36:08 by khais #+# #+# */
|
||||
/* Updated: 2025/04/10 15:36:44 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef SIMPLE_CMD_EXECUTE_DEBUG_H
|
||||
# define SIMPLE_CMD_EXECUTE_DEBUG_H
|
||||
|
||||
# include "../../minishell.h"
|
||||
|
||||
void simple_cmd_execute_debug(t_simple_cmd *cmd, t_minishell *app);
|
||||
|
||||
#endif // SIMPLE_CMD_EXECUTE_DEBUG_H
|
||||
|
|
@ -44,8 +44,9 @@ static void debug_command(t_cmd *cmd, t_minishell *app)
|
|||
{
|
||||
t_buffer *indent;
|
||||
|
||||
if (app->debug == false)
|
||||
if (app->debug == false || cmd == NULL)
|
||||
return ;
|
||||
ft_printf("parsed command\n");
|
||||
indent = ft_buffer_new();
|
||||
cmd_debug(cmd, indent, true);
|
||||
ft_buffer_free(indent);
|
||||
|
|
|
|||
|
|
@ -54,3 +54,12 @@ void simple_cmd_debug(t_simple_cmd *cmd, t_buffer *leader, bool is_last)
|
|||
redirect_debug(cmd->redirections, leader, true);
|
||||
dedent(leader, is_last);
|
||||
}
|
||||
|
||||
void simple_cmd_root_debug(t_simple_cmd *cmd)
|
||||
{
|
||||
t_buffer *leader;
|
||||
|
||||
leader = ft_buffer_new();
|
||||
simple_cmd_debug(cmd, leader, true);
|
||||
ft_buffer_free(leader);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/21 12:24:57 by khais #+# #+# */
|
||||
/* Updated: 2025/03/28 14:52:45 by khais ### ########.fr */
|
||||
/* Updated: 2025/04/10 15:33:10 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -22,5 +22,6 @@ t_simple_cmd *simple_cmd_from_wordlist(t_wordlist *words);
|
|||
void simple_cmd_destroy(t_simple_cmd *cmd);
|
||||
void simple_cmd_debug(t_simple_cmd *cmd, t_buffer *leader,
|
||||
bool is_last);
|
||||
void simple_cmd_root_debug(t_simple_cmd *cmd);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
4
test.sh
4
test.sh
|
|
@ -586,6 +586,7 @@ EOF
|
|||
expecting <<EOF
|
||||
[dbg: 1]
|
||||
[exec: 0]
|
||||
parsed command
|
||||
╰─ t_simple_cmd
|
||||
├─ line = 0
|
||||
├─ t_wordlist
|
||||
|
|
@ -615,6 +616,7 @@ EOF
|
|||
expecting <<EOF
|
||||
[dbg: 1]
|
||||
[exec: 0]
|
||||
parsed command
|
||||
╰─ t_simple_cmd
|
||||
├─ line = 0
|
||||
├─ t_wordlist
|
||||
|
|
@ -674,6 +676,7 @@ EOF
|
|||
expecting <<EOF
|
||||
[dbg: 1]
|
||||
[exec: 0]
|
||||
parsed command
|
||||
╰─ t_simple_cmd
|
||||
├─ line = 0
|
||||
├─ t_wordlist
|
||||
|
|
@ -733,6 +736,7 @@ EOF
|
|||
expecting <<EOF
|
||||
[dbg: 1]
|
||||
[exec: 0]
|
||||
parsed command
|
||||
╰─ t_simple_cmd
|
||||
├─ line = 0
|
||||
├─ t_wordlist
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue