Commit graph

181 commits

Author SHA1 Message Date
04eabf096d fix(wildcard): error detection in wordlist_expand_star
Will help in closing #167
2025-04-30 14:55:12 +02:00
a8c3473b1a fix(norm): khais -> kcolin in headers
Closes #184
2025-04-30 11:29:20 +02:00
95451520d6 fix(redirection): prevent fd leak in subprocess when doing redirection with multiple processes 2025-04-30 10:36:08 +02:00
3c350af411 fix(debug): print messages to STDERR, to prevent redirection by pipes etc 2025-04-29 13:16:47 +02:00
Jérôme Guélen
5c53ebfa64 (fix) Quote removal on heredoc limiters 2025-04-28 21:37:31 +02:00
92d647e33c feat(redirections): allow a command composed only of redirections 2025-04-28 14:44:20 +02:00
Jérôme Guélen
e5952b3f43
Behaviour seems inconsistent 2025-04-28 11:50:32 +02:00
7a5e838fcf fix(debug): wrong indent for group_cmd 2025-04-25 17:53:40 +02:00
e1801652af fix(parsing/subshell): missing allocation for group cmd 2025-04-25 17:52:51 +02:00
0c9dcd944e fix(parsing): report unclosed ( error 2025-04-25 13:19:44 +02:00
Jérôme Guélen
a86616f910
(enhancement) Printing an error on unclosed quote and corrected a typo. 2025-04-24 17:20:04 +02:00
b6e97ac2c7 fix(debug): redirectee prints both variants of an enum 2025-04-24 13:34:39 +02:00
3f08189aae fix(parsing/redirect): sometimes do not take a redirection into account
debug notes:

++++++++++++++++++++++++++++++++++++++++++++++++++++
failed: ambiguous redirect
++++++++++++++++++++++++++++++++++++++++++++++++++++
++++ test input:
export target="outfile1 outfile2"
echo hello > $target
echo $?
echo hi >> $target
echo $?
cat < $target
echo $?
ls
echo $?
++++ Got output:
hello
0
hi
0
echo $?
ls
echo $?
++++ But expected:
minishell: $target: ambiguous redirect
1
minishell: $target: ambiguous redirect
1
minishell: $target: ambiguous redirect
1
0

Reproduced this with rr record --cahos, see
/home/khais/.local/share/rr/minishell-48

$ export target="outfile1 outfile2"
$ echo hi > $target
hi

Break in simple_cmd_execute, second command has no redirections when it should
have some, presumably this comes from some uninitialized memory somewhere.
2025-04-24 13:26:40 +02:00
8d60113351 feat(postprocess/redir): remove quotes in redirection targets 2025-04-24 12:45:00 +02:00
aca85c3583 fix(expansion/redirection): prevent infinite loop of redir list pointing to itself
also add a hard limit of OVER 9000! iterations for the problematic loop
2025-04-24 12:45:00 +02:00
bf26afce2b fix(debug): correctly print here_doc_eof in redirect debug 2025-04-24 12:45:00 +02:00
2dd20b21bc feat(redir): fieldsplit redir target, and handle ambiguous redirects 2025-04-24 12:44:33 +02:00
5de82f2940 feat(debug): add function to easily treeprint a redirect 2025-04-21 11:00:14 +02:00
c00cc21ae4 feat(redirect): do variable expansion on redirect targets 2025-04-21 08:17:22 +02:00
701174fc1b feat(debug): function to easily treeprint a worddesc 2025-04-18 09:20:49 +02:00
9271b7fa92 fix(parsing/pipeline): leak when optional pipeline returns NULL 2025-04-18 09:19:25 +02:00
6cc6e6cfb5 feat(debug): add function to easily treeprint a cmd 2025-04-17 12:28:57 +02:00
f1a0af09f8 feat(here_doc): handle signals (^C, ^\) correctly
This is a bit of a big commit, because I had to move some stuff to other files,
sorry about that. I can split it up if it's too big to review.
2025-04-17 12:06:48 +02:00
5e6d7b3b4e fix(parsing/here_doc): segfault & invalid fd & premature exit 2025-04-17 11:25:59 +02:00
3be2969946 fix(parsing/simple_cmd): leak when invalid redirection after word in simple_cmd 2025-04-16 18:21:33 +02:00
96e46e9130 fix(parsing/cmdgroup): report error the same way as everywhere else, prevent double report
before:
```
$ ()
minishell: syntax error near unexpected token `)'
minishell: syntax error near unexpected token `)'
```
after:
```
$ ()
minishell: syntax error near unexpected token `)'
```
This probably fixes a few bugs as well, but I didn't look too hard. It just
seemed nicer to have a consistent way to report errors.
2025-04-16 15:52:22 +02:00
ced979dd31 fix(parsing/simple_cmd): report error the same way as everywhere else, prevent leak 2025-04-16 15:38:51 +02:00
d652f32cff feat(debug): a way to easily debug a wordlist 2025-04-16 15:30:18 +02:00
9a32220945 redir_parsing: fix memory leak when parsing a redirection with an operator as specifier
if the specifier was not WORD_TOKEN, the operator was not being freed
2025-04-16 14:13:01 +02:00
84a246f6f6 parsing: fix redir accepting operators as specifiers
before:
$ >>>>>
minishell: syntax error near unexpected token `newline'

after:
$ >>>>>
minishell: syntax error near unexpected token `>>'

>> is now correctly detected as an operator, and not a word
2025-04-16 13:59:14 +02:00
9593851149 parsing: show errors for unexpected newline
$ <
minishell: syntax error near unexpected token `newline'
$ >
minishell: syntax error near unexpected token `newline'
$ <<
minishell: syntax error near unexpected token `newline'
$ >>
minishell: syntax error near unexpected token `newline'
2025-04-16 13:16:34 +02:00
e1a1a43041 parsing: refactor cmds_parse into own file 2025-04-16 13:13:55 +02:00
73d691c0b4 parsing: refactor group_or_simple_parse into group_cmd_parse.c 2025-04-16 13:08:50 +02:00
a5103fa733 clean: remove unused paren files 2025-04-16 13:05:34 +02:00
dd30b44b93 parsing: refactor minishell_opt_cmds_parse into own file 2025-04-16 13:03:49 +02:00
81ba53237c parsing: do not reset last_return_value at start of parsing
we need to preserve it, to be able to show the return value from the last command
2025-04-15 15:45:29 +02:00
81febcfcdd
debug: show command about to be executed in debug mode 2025-04-15 15:19:27 +02:00
596b21fc2f
debug, destroy all new types (also some code for testing it) 2025-04-15 15:17:51 +02:00
3ec90f7770
token_type: assign token_type to worddesc during wordsplit
Also added some tests for that part.
2025-04-15 15:17:51 +02:00
4d6a64bf6a
debug: worddesc show more information
This seems appropriate since worddescs are getting more and more complex:
markers, flags, tokentypes, ...
2025-04-15 15:17:51 +02:00
18014cda98
token_type: add field with no logic for populating it 2025-04-15 15:15:30 +02:00
5716c4b3dc parsing: pass correct arguments to prevent use-after-free 2025-04-15 15:15:30 +02:00
4de1d0024a parsing: refactor out the last two functions needed to pass the norm 2025-04-15 14:41:43 +02:00
5e84e9a111 parsing: remove (at least some) dead code 2025-04-15 14:41:43 +02:00
218be08049 parsing: refactor group_cmd_parse into own file 2025-04-15 14:41:43 +02:00
b7871be426 parsing: refactor minishell_optional_pipeline_parse into own file 2025-04-15 14:41:43 +02:00
811ce3ef8e parsing: refactor minishell_simple_cmd_parse into own file 2025-04-15 14:41:43 +02:00
9a58198303 parsing: refactor minishell_redirect_parse to own file 2025-04-15 14:41:43 +02:00
d4197fec38 parsing: create specialised function to create a t_cmd 2025-04-15 14:41:43 +02:00
fde0bf4dc9 parsing: refactor: simple norm linecount gains 2025-04-15 14:41:43 +02:00