Skip to content

Vinni-Cedraz/minishell

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minishell

the minishell project is about making a shell with some bash features

the bnf notation:

<Command> ::= [<Redirection>] <Word> <Argument>* | (<Command> (<Redirection> | <Logics> | <Pipe>) <Command>)
<Pipe> ::= '|' 
<Logics> ::=  '&&' | '||'
<Redirection> ::= '<' | '<<' | '>>' | '>'
<Argument> ::= (['-' | '--'] <Word>)+
<Word> ::= <File> | <String>

machine state:

         1      2      3      4      5     6     7     8     9
state | '<<' | '>>' | '||' | '&&' | '|' | '&' | '<' | '>' | WORD
0     |  1   |  2   | -1   | -1   | -1  | -1  |  7  |  8  | 9
1     |  9   | -1   | -1   | -1   | -1  | -1  |  -1 | -1  | 9
2     | -1   | -1   | -1   | -1   | -1  | -1  | -1  | -1  | 9
3     | -1   | -1   | -1   | -1   | -1  | -1  | -1  | -1  | 9
4     | -1   | -1   | -1   | -1   | -1  | -1  | -1  | -1  | 9
5     | -1   |  9   | -1   | -1   | -1  | -1  |  9  |  9  | 9
6     | -1   | -1   | -1   | -1   | -1  | -1  | -1  | -1  | 9
7     | -1   | -1   | -1   | -1   | -1  | -1  | -1  | -1  | 9
8     | -1   | -1   | -1   | -1   | -1  | -1  | -1  | -1  | 9
9     |  1   |  2   |  3   |  4   |  5  |  6  | 7   | 8   | 9

TODO

  • Display a prompt when waiting for a new command

  • Have a working history

  • Not use more than one global variable. Think about it. You will have to explain its purpose

  • Not interpret unclosed quotes or special characters which are not required by the subject such as \ (backslash) or ; (semicolon).

  • ctrl-C displays a new prompt on a new line.

  • ctrl-D exits the shell.

  • ctrl-\ does nothing.

  • Handle $? which should expand to the exit status of the most recently executed foreground pipeline.

  • Handle environment variables ($ followed by a sequence of characters) which should expand to their values.

  • Handle ’ (single quote) which should prevent the shell from interpreting the meta-characters in the quoted sequence.

  • Handle " (double quote) which should prevent the shell from interpreting the meta-characters in the quoted sequence except for $ (dollar sign).

  • Search and launch the right executable (based on the PATH variable or using a relative or an absolute path

  • < should redirect input.

  • > should redirect output.

  • << should be given a delimiter, then read the input until a line containing the delimiter is seen. However, it doesn’t have to update the history!

  • >> should redirect output in append mode.

  • Implement pipes (| character). The output of each command in the pipeline is connected to the input of the next command via a pipe.

Your shell must implement the following builtins:

  • echo with option -n

  • cd with only a relative or absolute path

  • pwd with no options

  • export with no options

  • unset with no options

  • env with no options or arguments

  • exit with no options

PROBLEMS

  • PODE SER INPUT E OUTPUT

  • Exit after export leaks

  • Finish interpolation

  • Make redirections work with child processes

  • Heredoc doesn't close

  • Heredoc doesn't break after SIGINT

About

a minishell

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 96.4%
  • Makefile 3.6%