minishell
A School 21 project. Write your own shell.
You should watch intranet tutorials! Though I couldn’t find them…
# Lexer and parser
I want to implement a Recursive descent parser. UPD: I gave up the bonus part. Recursive descent parser is an overkill for the mandatory part, but whatever.
# Clean-up
Should I call rl_clear_history
? There are no leaks, even if I don’t call it.
# Exiting shell
# Notes on Bash behavior
It doesn’t matter where exactly you put redirects (>
, >>
):
|
|
If the output is both redirected to a file and piped to the next command, it won’t be piped, only written to a file.
|
|
|
(pipe) has higher priority than &&
/||
.
Backslash \
escapes one special char (space, &
, |
, maybe others).
Seems like we don’t have to implement command substitution ($(...)
), only environment variables (like $PWD
).
&&
and ||
have equal precedence and are executed left to right. Use ()
to change priority. UPD: ()
actually creates a subshell. So stuff like this is valid:
|
|
According to the checklist, “()
should behave like in Bash”. Goodbye bonus part, then.
Some examples of how Bash does stuff:
|
|
Links
- BNF for bash
- Bash V2 grammar
- Shell Command Language
- Bash Reference Manual
- Bash parsing stages
- In what order does Bash parser escape characters and split words/tokens within command line?
# Non-tty mode
Minishell should work not only as an interactive shell, but as an interpreter too (if I understood the subject right):
|
|