mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
redirection parsing: handle > at start of wordlist
This commit is contained in:
parent
541bad80c0
commit
a20ea8315d
2 changed files with 52 additions and 4 deletions
|
|
@ -5,8 +5,8 @@
|
|||
/* +:+ +:+ +:+ */
|
||||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/03/07 11:55:37 by khais #+# #+# */
|
||||
/* Updated: 2025/03/07 14:43:15 by khais ### ########.fr */
|
||||
/* Created: 2025/03/07 14:47/34 by khais #+# #+# */
|
||||
/* Updated: 2025/03/07 14:47:34 by khais ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,6 +14,9 @@
|
|||
#include "../src/parser/simple_cmd/simple_cmd.h"
|
||||
#include "../src/parser/wordsplit/wordsplit.h"
|
||||
#include "../src/postprocess/redirections/redirection_parsing.h"
|
||||
#include "../src/postprocess/redirections/redirection_parsing.h"
|
||||
#include "../src/postprocess/redirections/redirection_list.h"
|
||||
#include "testutil.h"
|
||||
|
||||
static t_simple_cmd *parse_simple_cmd(char *input)
|
||||
{
|
||||
|
|
@ -28,9 +31,28 @@ static void test_redirection_parsing_no_redirections(void)
|
|||
assert(parse_redirections(cmd) != NULL);
|
||||
assert(cmd->redirections == NULL);
|
||||
simple_cmd_destroy(cmd);
|
||||
do_leak_check();
|
||||
}
|
||||
|
||||
static void test_redirection_parsing_output_at_start(void)
|
||||
{
|
||||
t_simple_cmd *cmd = parse_simple_cmd(">outfile echo hello world");
|
||||
assert(parse_redirections(cmd) != NULL);
|
||||
assert_strequal("outfile", cmd->redirections->redirection->marker->word);
|
||||
assert(cmd->redirections->redirection->type == REDIR_OUTPUT);
|
||||
assert(cmd->redirections->next == NULL);
|
||||
assert_strequal("echo", cmd->words->word->word);
|
||||
assert_strequal("hello", cmd->words->next->word->word);
|
||||
assert_strequal("world", cmd->words->next->next->word->word);
|
||||
assert(NULL == cmd->words->next->next->next);
|
||||
simple_cmd_destroy(cmd);
|
||||
do_leak_check();
|
||||
}
|
||||
|
||||
|
||||
int main(void) {
|
||||
test_redirection_parsing_no_redirections();
|
||||
test_redirection_parsing_output_at_start();
|
||||
// check operator alone without further tokens
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue