Closed iaurg closed 2 years ago
redirection:
Our shell:
cat <<
$cat: '<<': No such file or directory
Bash:
cat <<
$ bash: syntax error near unexpected token `newline'
Our shell:
cat < <
$ minishell: no such file or directory: <
$ cat: '<': No such file or directory
Bash:
cat < <
$ bash: syntax error near unexpected token `<'
Trying to write into a missing file
[ minishell ]$ heredoc.txt << END
… test here doc
… END
minishell: heredoc.txt: No such file or directory
==28441== Syscall param execve(filename) points to unaddressable byte(s)
==28441== at 0x499E17B: execve (syscall-template.S:78)
==28441== by 0x4017A2: execute_child_command (execute_system.c:84)
==28441== by 0x401874: system_exec (execute_system.c:99)
==28441== by 0x4014CF: execute (execute.c:56)
==28441== by 0x4021C5: handle_execute (pipe.c:79)
==28441== by 0x401F16: minishell (minishell.c:68)
==28441== by 0x403143: main (main.c:22)
==28441== Address 0x0 is not stack'd, malloc'd or (recently) free'd
cat << EOF > print.sh
… echo $PWD
… EOF
==29304== Invalid read of size 1
==29304== at 0x4016A5: command_comes_first (execute_system.c:40)
==29304== by 0x40170A: handle_first_arg (execute_system.c:59)
==29304== by 0x40177C: execute_child_command (execute_system.c:81)
==29304== by 0x401874: system_exec (execute_system.c:99)
==29304== by 0x4014CF: execute (execute.c:56)
==29304== by 0x4021C5: handle_execute (pipe.c:79)
==29304== by 0x401F16: minishell (minishell.c:68)
==29304== by 0x403143: main (main.c:22)
==29304== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==29304==
==29304==
==29304== Process terminating with default action of signal 11 (SIGSEGV)
==29304== Access not within mapped region at address 0x0
==29304== at 0x4016A5: command_comes_first (execute_system.c:40)
==29304== by 0x40170A: handle_first_arg (execute_system.c:59)
==29304== by 0x40177C: execute_child_command (execute_system.c:81)
==29304== by 0x401874: system_exec (execute_system.c:99)
==29304== by 0x4014CF: execute (execute.c:56)
==29304== by 0x4021C5: handle_execute (pipe.c:79)
==29304== by 0x401F16: minishell (minishell.c:68)
==29304== by 0x403143: main (main.c:22)
==29304== If you believe this happened as a result of a stack
==29304== overflow in your program's main thread (unlikely but
==29304== possible), you can try to increase the size of the
==29304== main thread stack using the --main-stacksize= flag.
==29304== The main thread stack size used in this run was 8388608.
==29304==
==29304== HEAP SUMMARY:
==29304== in use at exit: 211,024 bytes in 504 blocks
==29304== total heap usage: 1,435 allocs, 936 frees, 277,540 bytes allocated
==29304==
==29304== LEAK SUMMARY:
==29304== definitely lost: 32 bytes in 1 blocks
==29304== indirectly lost: 34 bytes in 2 blocks
cat << EOF
… The current working directory is: $PWD
… EOF
==29885== Invalid read of size 8
==29885== at 0x401CF7: sanitize_argv (here_doc.c:80)
==29885== by 0x401DE7: read_input (here_doc.c:117)
==29885== by 0x401F0A: minishell (minishell.c:66)
==29885== by 0x403143: main (main.c:22)
==29885== Address 0x4b2aeb0 is 0 bytes after a block of size 32 alloc'd
==29885== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==29885== by 0x403FF0: ft_calloc (in /home/italo/Documents/Studies/42/42-minishell/minishell)
==29885== by 0x402C28: handle_tokens (tokens.c:96)
==29885== by 0x401DBB: read_input (here_doc.c:103)
==29885== by 0x401F0A: minishell (minishell.c:66)
==29885== by 0x403143: main (main.c:22)
==29885==
The current working directory is: $PWD
Errors with examples: https://linuxize.com/post/bash-heredoc/
cat << EOF > file.txt
Different return:
Our shell:
echo "hi" >> >> test.txt
Print "hi >>" inside text.txt file
Bash:
echo "hi" >> >> test.txt
$bash: syntax error near unexpected token `>>'
Different return:
Our shell:
echo | |
$
Bash:
echo | |
$bash: syntax error near unexpected token `|'
Our shell:
<
$minishell: no such file or directory: (null)
Bash:
<
bash: syntax error near unexpected token `newline'
Our shell:
cat <|
$ cat: '<|': No such file or directory
Bash:
cat <|
$ bash: syntax error near unexpected token `|'
Our shell:
a
$minishell: a: No such file or directory
Bash:
a
$a: command not found
cat | cat | ls
Show ls after CTRL + C
Validar na workspace
Comandos que precisam executar e funcionar em "combo"
~export TEST1=1 TEST2=2 TEST3=3~
~unset TEST1=1 TEST2=2 TEST3=3~
export without paramscd >Error:
~echo hello>world~
does nothing, in bash this fill the file
echo $TERM print the first element found with "TERM" on name, instead of printing out TERM variable the shell founds TERM_PROGRAM and print it.cat pipe-test.txt | sort | uniq > ordered.txt
cat minishell | wc -lOur shell parse ">" as a redirection instead of a string
Some inconsistency on echo:
bash:
In our minishell returns empty