mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
136 lines
6.8 KiB
Text
136 lines
6.8 KiB
Text
++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||
redirections are parsed
|
||
++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||
++++ Failed test:
|
||
echo hello < in hi > out
|
||
++++ Got output:
|
||
╰─ t_cmdgroup
|
||
├─ t_cmdlist
|
||
│ ├─ num_cmds = 1
|
||
│ ╰─ cmd[0]
|
||
│ ├─ t_cmdlist_item
|
||
│ │ ╰─ t_pipeline
|
||
│ │ ├─ num_cmd = 1
|
||
│ │ ╰─ cmd[0]
|
||
│ │ ╰─ t_simple_cmd
|
||
│ │ ├─ words = [echo][hello][hi]
|
||
│ │ ╰─ t_redir_list
|
||
│ │ ├─ redirection[0]
|
||
│ │ │ ╰─ t_redirection
|
||
│ │ │ ├─ t_redir_type = REDIR_INPUT
|
||
│ │ │ ╰─ marker = [in]
|
||
│ │ ╰─ redirection[1]
|
||
│ │ ╰─ t_redirection
|
||
│ │ ├─ t_redir_type = REDIR_OUTPUT
|
||
│ │ ╰─ marker = [out]
|
||
│ ╰─ t_operator = END
|
||
╰─ (no redirections)
|
||
++++ But expected:
|
||
╰─ t_cmdgroup
|
||
├─ t_cmdlist
|
||
│ ├─ num_cmds = 1
|
||
│ ╰─ cmd[0]
|
||
│ ├─ t_cmdlist_item
|
||
│ │ ╰─ t_pipeline
|
||
│ │ ├─ num_cmd = 1
|
||
│ │ ╰─ cmd[0]
|
||
│ │ ╰─ t_simple_cmd
|
||
│ │ ├─ words = [echo][hello][hi]
|
||
│ │ ╰─ t_redir_list
|
||
│ │ ├─ redirection[0]
|
||
│ │ │ ╰─ t_redirection
|
||
│ │ ╰─ redirection[1]
|
||
│ │ ╰─ t_redirection
|
||
│ ╰─ t_operator = END
|
||
╰─ (no redirections)
|
||
++++ Diff:
|
||
(red is got, green is expected)
|
||
[36m14,15d13[0m
|
||
[31m< │ │ │ ├─ t_redir_type = REDIR_INPUT[0m
|
||
[31m< │ │ │ ╰─ marker = [in][0m
|
||
[36m18,19d15[0m
|
||
[31m< │ │ ├─ t_redir_type = REDIR_OUTPUT[0m
|
||
[31m< │ │ ╰─ marker = [out][0m
|
||
++++ Run this to debug:
|
||
echo 'echo hello < in hi > out' | ./minishell
|
||
++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||
multiple redirections are parsed
|
||
++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||
++++ Failed test:
|
||
echo << HERE_DOC hello>outfile < infile < infile2 >> append
|
||
++++ Got output:
|
||
╰─ t_cmdgroup
|
||
├─ t_cmdlist
|
||
│ ├─ num_cmds = 1
|
||
│ ╰─ cmd[0]
|
||
│ ├─ t_cmdlist_item
|
||
│ │ ╰─ t_pipeline
|
||
│ │ ├─ num_cmd = 1
|
||
│ │ ╰─ cmd[0]
|
||
│ │ ╰─ t_simple_cmd
|
||
│ │ ├─ words = [echo][hello]
|
||
│ │ ╰─ t_redir_list
|
||
│ │ ├─ redirection[0]
|
||
│ │ │ ╰─ t_redirection
|
||
│ │ │ ├─ t_redir_type = REDIR_HERE_DOC
|
||
│ │ │ ╰─ marker = [HERE_DOC]
|
||
│ │ ├─ redirection[1]
|
||
│ │ │ ╰─ t_redirection
|
||
│ │ │ ├─ t_redir_type = REDIR_OUTPUT
|
||
│ │ │ ╰─ marker = [outfile]
|
||
│ │ ├─ redirection[2]
|
||
│ │ │ ╰─ t_redirection
|
||
│ │ │ ├─ t_redir_type = REDIR_INPUT
|
||
│ │ │ ╰─ marker = [infile]
|
||
│ │ ├─ redirection[3]
|
||
│ │ │ ╰─ t_redirection
|
||
│ │ │ ├─ t_redir_type = REDIR_INPUT
|
||
│ │ │ ╰─ marker = [infile2]
|
||
│ │ ╰─ redirection[4]
|
||
│ │ ╰─ t_redirection
|
||
│ │ ├─ t_redir_type = REDIR_APPEND
|
||
│ │ ╰─ marker = [append]
|
||
│ ╰─ t_operator = END
|
||
╰─ (no redirections)
|
||
++++ But expected:
|
||
|
||
++++ Diff:
|
||
(red is got, green is expected)
|
||
[36m1,33c1[0m
|
||
[31m< ╰─ t_cmdgroup[0m
|
||
[31m< ├─ t_cmdlist[0m
|
||
[31m< │ ├─ num_cmds = 1[0m
|
||
[31m< │ ╰─ cmd[0][0m
|
||
[31m< │ ├─ t_cmdlist_item[0m
|
||
[31m< │ │ ╰─ t_pipeline[0m
|
||
[31m< │ │ ├─ num_cmd = 1[0m
|
||
[31m< │ │ ╰─ cmd[0][0m
|
||
[31m< │ │ ╰─ t_simple_cmd[0m
|
||
[31m< │ │ ├─ words = [echo][hello][0m
|
||
[31m< │ │ ╰─ t_redir_list[0m
|
||
[31m< │ │ ├─ redirection[0][0m
|
||
[31m< │ │ │ ╰─ t_redirection[0m
|
||
[31m< │ │ │ ├─ t_redir_type = REDIR_HERE_DOC[0m
|
||
[31m< │ │ │ ╰─ marker = [HERE_DOC][0m
|
||
[31m< │ │ ├─ redirection[1][0m
|
||
[31m< │ │ │ ╰─ t_redirection[0m
|
||
[31m< │ │ │ ├─ t_redir_type = REDIR_OUTPUT[0m
|
||
[31m< │ │ │ ╰─ marker = [outfile][0m
|
||
[31m< │ │ ├─ redirection[2][0m
|
||
[31m< │ │ │ ╰─ t_redirection[0m
|
||
[31m< │ │ │ ├─ t_redir_type = REDIR_INPUT[0m
|
||
[31m< │ │ │ ╰─ marker = [infile][0m
|
||
[31m< │ │ ├─ redirection[3][0m
|
||
[31m< │ │ │ ╰─ t_redirection[0m
|
||
[31m< │ │ │ ├─ t_redir_type = REDIR_INPUT[0m
|
||
[31m< │ │ │ ╰─ marker = [infile2][0m
|
||
[31m< │ │ ╰─ redirection[4][0m
|
||
[31m< │ │ ╰─ t_redirection[0m
|
||
[31m< │ │ ├─ t_redir_type = REDIR_APPEND[0m
|
||
[31m< │ │ ╰─ marker = [append][0m
|
||
[31m< │ ╰─ t_operator = END[0m
|
||
[31m< ╰─ (no redirections)[0m
|
||
---
|
||
[32m> [0m
|
||
++++ Run this to debug:
|
||
echo 'echo << HERE_DOC hello>outfile < infile < infile2 >> append' | ./minishell
|