mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
fix(parsing/subshell): missing allocation for group cmd
This commit is contained in:
parent
9fcb34e1d5
commit
e1801652af
2 changed files with 51 additions and 2 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/15 10:46:28 by khais #+# #+# */
|
/* Created: 2025/04/15 10:46:28 by khais #+# #+# */
|
||||||
/* Updated: 2025/04/17 12:27:05 by khais ### ########.fr */
|
/* Updated: 2025/04/25 17:38:11 by khais ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
#include "../redirect/redirect_parse.h"
|
#include "../redirect/redirect_parse.h"
|
||||||
#include "../simple_cmd/simple_cmd_parse.h"
|
#include "../simple_cmd/simple_cmd_parse.h"
|
||||||
#include "../cmd/cmds_parse.h"
|
#include "../cmd/cmds_parse.h"
|
||||||
#include "../cmd/cmd_debug.h"
|
|
||||||
|
|
||||||
t_cmd *minishell_group_cmd_parse(t_minishell *app, t_wordlist **tokens)
|
t_cmd *minishell_group_cmd_parse(t_minishell *app, t_wordlist **tokens)
|
||||||
{
|
{
|
||||||
|
|
@ -32,6 +31,9 @@ t_cmd *minishell_group_cmd_parse(t_minishell *app, t_wordlist **tokens)
|
||||||
group = cmd_create(FT_GROUP);
|
group = cmd_create(FT_GROUP);
|
||||||
if (!group)
|
if (!group)
|
||||||
return (cmd_destroy(subtree), NULL);
|
return (cmd_destroy(subtree), NULL);
|
||||||
|
group->value.group = ft_calloc(1, sizeof(t_group_cmd));
|
||||||
|
if (!group->value.group)
|
||||||
|
return (cmd_destroy(subtree), NULL);
|
||||||
group->value.group->cmd = subtree;
|
group->value.group->cmd = subtree;
|
||||||
group->value.group->redirects = minishell_redirect_parse(app, tokens);
|
group->value.group->redirects = minishell_redirect_parse(app, tokens);
|
||||||
if (group->value.group->redirects == NULL
|
if (group->value.group->redirects == NULL
|
||||||
|
|
|
||||||
47
test.sh
47
test.sh
|
|
@ -1237,4 +1237,51 @@ minishell: cd: file: Not a directory
|
||||||
1
|
1
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
when_run <<EOF "subshell"
|
||||||
|
touch hi hello
|
||||||
|
(ls)
|
||||||
|
EOF
|
||||||
|
expecting <<EOF
|
||||||
|
hello
|
||||||
|
hi
|
||||||
|
EOF
|
||||||
|
|
||||||
|
when_run <<EOF "subshell within subshell"
|
||||||
|
touch hi hello
|
||||||
|
((ls))
|
||||||
|
EOF
|
||||||
|
expecting <<EOF
|
||||||
|
hello
|
||||||
|
hi
|
||||||
|
EOF
|
||||||
|
|
||||||
|
when_run <<EOF "subshell within and"
|
||||||
|
touch hi hello
|
||||||
|
ls && (ls)
|
||||||
|
EOF
|
||||||
|
expecting <<EOF
|
||||||
|
hello
|
||||||
|
hi
|
||||||
|
hello
|
||||||
|
hi
|
||||||
|
EOF
|
||||||
|
|
||||||
|
when_run <<EOF "subshell within or"
|
||||||
|
touch hi hello
|
||||||
|
(ls) || ls
|
||||||
|
EOF
|
||||||
|
expecting <<EOF
|
||||||
|
hello
|
||||||
|
hi
|
||||||
|
EOF
|
||||||
|
|
||||||
|
when_run <<EOF "exit within subshell within or"
|
||||||
|
touch hi hello
|
||||||
|
(exit 1) || ls
|
||||||
|
EOF
|
||||||
|
expecting <<EOF
|
||||||
|
hello
|
||||||
|
hi
|
||||||
|
EOF
|
||||||
|
|
||||||
finalize
|
finalize
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue