Code Monkey home page Code Monkey logo

minishell's Introduction

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

  • [x?] Exit after export leaks

  • Finish interpolation

  • Make redirections work with child processes

  • Heredoc doesn't close

  • Heredoc doesn't break after SIGINT

minishell's People

Contributors

vinni-cedraz avatar astahjmo avatar github-user-name avatar loenasci avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.