forked from AdriiE17/minishell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
guide
95 lines (77 loc) · 3.15 KB
/
guide
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
main
└─> print_version
└─> initialize_shell
└─> while(1)
├─> handle_prompt
│ ├─> construct_prompt
│ └─> readline(prompt)
├─> handle_exit
└─> process_line
├─> add_history
├─> process_command
│ ├─> exp_env_vars
│ │ ├─> handle_special_chars
│ │ ├─> expand_variable
│ │ └─> expand_exit_status
│ ├─> split_args
│ ├─> execute_pipeline
│ │ ├─> fork
│ │ └─> handle_child
│ │ ├─> split_args
│ │ ├─> handle_pipe_redirection
│ │ ├─> execute_and_handle_error
│ │ ├─> handle_builtin
│ │ ├─> handle_signal
│ │ └─> execve
└─> free(line)
# Prueba 1: Redirección y comillas
/bin/echo "hola mundo" > file
ls # Esperado: file
cat test_file # Esperado: hola mundo
✓
# Prueba 2: Comillas y contenido especial
/bin/echo 'texto "entre comillas"' > quoted_file
ls # Esperado: quoted_file
cat quoted_file # Esperado: texto "entre comillas"
✓
# Prueba 3: Tuberías y redirección combinadas
/bin/echo "texto con tuberías y > redirección" | cat > pipe_file
ls # Esperado: pipe_file
cat pipe_file # Esperado: texto con tuberías y > redirección
✓
# Prueba 4: Redirección inválida con comillas
/bin/echo hola > "\"weird_file\""
ls # Esperado: "weird_file"
cat "\"weird_file\"" # Esperado: hola
# Prueba 5: Caracteres especiales en nombres de archivo
/bin/echo "contenido especial" > "file with spaces.txt"
ls # Esperado: file with spaces.txt
cat "file with spaces.txt" # Esperado: contenido especial
# no ejecuta
/bin/echo -n hola
/bin/echo -nnnnnn hola
/bin/echo -n -nn -nnn hola
/bin/echo -n -na hola
-na hola%
/bin/echo \"\'\'\'\"
incorrecto \\'\'\'\
correcto "'''"
/bin/echo \"'''\"
>
cat * | sed -e 's/\/\*.*\*\// /g' -e '/\/\*/,/\*\//d' -e '/^[[:space:]]*$/d'
^[[200~/bin/echo hola > a
execve: Command not found: No such file or directory
=================================================================
==2380671==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 4 byte(s) in 2 object(s) allocated from:
#0 0x485f34 in strdup (/home/vberdugo/Projects/minishell/minishell+0x485f34)
#1 0x4db220 in remove_q /home/vberdugo/Projects/minishell/src/quotes.c:71:7
#2 0x4db84d in process_string /home/vberdugo/Projects/minishell/src/quotes.c:99:2
#3 0x4d0460 in handle_child /home/vberdugo/Projects/minishell/src/pipes.c:81:3
#4 0x4d1163 in handle_pipeline /home/vberdugo/Projects/minishell/src/pipes.c:114:4
#5 0x4d192b in execute_pipeline /home/vberdugo/Projects/minishell/src/pipes.c:132:2
#6 0x4d4771 in process_command /home/vberdugo/Projects/minishell/src/mini_utils.c:117:3
#7 0x4d4f2d in process_line /home/vberdugo/Projects/minishell/src/signals.c:115:2
#8 0x4cb5b0 in main /home/vberdugo/Projects/minishell/src/minishell.c:32:3
#9 0x7f1d7dbc1d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
SUMMARY: AddressSanitizer: 4 byte(s) leaked in 2 allocation(s).