Code Monkey home page Code Monkey logo

42sh's Introduction

42sh

Time has come. Make way for the famous 42sh!

Required package installation (linux)

sudo apt install libncurses5-dev

Keybindings

KEY FUNCTION
right Move cursor right.
left Move cursor left.
ctrl+right Move cursor to the beginning of a word.
ctrl+left Move cursor to the ending of a word.
ctrl+up Move cursor to the upper line.
ctrl+down Move cursor to the lower line.
up Navigate to older command in history.
down Navigate to newer command in history.
ctrl+r Reverse-i-search.
home Move cursor to the beginning of current command.
end Move cursor to the ending of current command.
ctrl+l Clear input buffer.
ctrl+u Cut left side of the command from cursor.
ctrl+k Cut right side of the command from cursor.
ctrl+p Paste internal clipboard content.

Mandatory part

  • Minishell prerequisites
    • Prompt display
    • Run commands with their parameters and PATH monitoring
    • Error monitoring without using erno, and return values of commands
    • Correct spaces and tabulations monitoring
  • 21sh prerequisites
    • Full edition of command line
    • Redirection and aggregation operators
    • Pipe
    • Separator
  • Built-ins
    • cd
    • echo
    • exit
    • type
  • Logical operators
    • "&&"
    • "||"
  • Monitoring of internal shell variables
    • Internal variable creation depending on syntax: name=value
    • Internal variable exportation to the enviroment via built-in export
    • Possibility to list shell internal variables via built-in set
    • Internal and enviroment variables revocation via built-in unset
    • Enviroment variable creation for unique command
    • Simple expansion of parameters depending on syntax ${} (syntax is $EXPANSION)
    • Exit code access of previous command via expansion ${?} (syntax is $?)
    • Job control monitoring with built-ins jobs, fg, bg and the & operator
    • Correct monitoring of all signals
    • Each built-in must have the enounced options by POSIX standard execept for explicit case ad set or unset

Modular Part Features

  • Inhibitors โ€ (double quote), โ€™ (simple quote) and \.
  • Complete management of the history.
  • Alias management via built-ins alias and unalias.
  • A hash table and built-in hash to interact with it.
  • Contextual dynamic completion.
  • Built-in test with the required operators.

Issues

  • New opening quote in open quote.
  • Trailing pipe not implemented.
  • Fc carbage. Rewrite the whole built-in.
  • Line edition with command including newlines.
  • History exclamation expanded even if inside single quotes.
    • Exclamation parsing needs to be transfered to parser.
  • Lexer does not recognize specified fd ie. 2> and 2>&1.
    • Redirection with specified fd ie. 2> does not work.
    • Redireciton with multiple specified fd ie. 2>&1 does not work.
  • Specific process should have own return value recorded after completion.
  • Cursor movement does not work with ctrl+key combination after commit 098687956be52f87e71d9ad68a4ce5d76ebe96ce, which fixed line edition with command including newlines.
  • Absolute path for the file where history commands are saved in.
  • Cd builtin does not align with the POSIX standard.
  • Type builtin cannot handle alias specification because aliases are expanded in lexer. (comment: use single quotes to avoid this.)
  • Shady stuff going on with the alias and unalias control including hashmap functions. Segfaults.
  • Two or more consecutive expandable aliases cause segmentation fault.
  • Export builtin can only modify existing enviroment variables. It cannot create new ones.
  • $ expansion segmentation fault if there is no value.
  • ~ expansion segmentation fault if there is no value in HOME.
  • $ expansion wont work if the expandable value is joined with slash ie. $HOME/Documents.
  • Invalid pointer being freed sometimes when alias expansion is done.
  • Shell "freezes" if job is stopped.
  • Set signals to default when bringing job to the foreground.
  • Decide when and where shell updates current and previous jobs (current handling is supported).
  • Shady stuff going on when signal is sent to a process via kill. Try fix signals.
    • There is no way for the programs to know about sent signals if they are in background or stopped.
  • Improve line edition (up and down)
  • Odd files being created to directory when history file fills up to the limit.
  • Reverse-i-search segfault.
  • segfault with command "alias=hello'"
  • hash builtin POSIX standard?
  • segfault when file is redireced as input.
  • condition neglects job control.

Less serious issues.

  • Aliases are expanded in lexer. This means that if the user wishes to find out specific alias using alias builtin, the argument has to be inside single quotes. Same syntax should be carried out when adding aliases to avoid undefined behavior.
  • Dollar sign should be put into single quotes if user wants to write the character into std_out, otherwise parser will erase it when expanding dollars.
  • When using kill command the termination of background jobs works well. Stopped jobs have to be raised to the foreground so they can exit.

Jocke:

  • Check builtin POSIX standard.
  • Fix easy norminette errors from src folder (Please don't alter code too much and make pull requests for each folder.)
  • Hunt for leaks outside autocomplete.
  • Keep list of every segfaut, invalid pointer free etc. and what command led to program crash.

42sh's People

Contributors

biffenx avatar salahadawi avatar

Watchers

James Cloos 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.