Skip to content

21sh-42sh is a Linux CLI (Command Line Interface) thought, designed, and made by chbravo-, gpouyat, jlasne and mleroy for the 42 school as the last project before their first internship.

Notifications You must be signed in to change notification settings

cbcercas/21sh-42sh

Repository files navigation

21sh-42sh

Open Source Love PRs Welcome

Introduction

21sh-42sh is a Linux CLI (Command Line Interface) thought, designed, and made by chbravo-, gpouyat, jlasne and mleroy for the school 42 as the last project before their first internship.

Final grade for 21sh: 100

Final grade for 42sh: 74

Installation | Compilation

To compile 21sh-42sh, first clone the project with the submodules (git clone https://github.com/cbcercas/21sh-42sh.git --recursive --branch master to clone the branch master for example). Once cloned and moved into the directory, type make. 21-42sh auto-configures the build process, so no further intervention should be necessary. 21-42sh builds with clang by default if it is available. If you want to use gcc instead, type make CC=gcc

The DEV and SAN flags are avaibles if you want to enable -g or fsanetize

Reporting bugs

Bug reports for 21sh-42sh should be reported in the issues section on our Github page along with:

  • the version number (if available, else the commit used by the last build)
  • the machine and OS that it is running on
  • a list of the compilation flags
  • a list of the flags passed to the shell
  • a description of the bug
  • a recipe for recreating the bug reliably
  • a fix for the bug if you have one!

Features

  • Line editing

    • Simple and advanced line editing
    • Edit the line where the cursor is positionned
    • Move cursor left or right
    • Up and Down arrows to navigate in the history
    • Enter Insert mode with alt+i and exit it with alt+i
    • Copy and paste with alt+C alt+v
    • Move word per word left or right alt+LEFT alt+RIGHT
    • Go to beginning or end of a line. home end
    • Move to top or bottom line. alt+UP alt+DOWN
    • Waits for the end of a quote or double quote.
    • ctrl+D and ctrl+C usable when editing a line or in multi-line.
    • Multiline line editing
  • Builtins with their POSIX options (For more info type help once in the shell)

    • cd | chdir
    • echo
    • exit
    • env
    • setenv
    • unsetenv
    • unset
    • export
    • history
    • pwd
  • Exec

    • Executing commands stored in path with their parameters
    • Error handling and return value handling
    • Smiley face based on return value from previous command (^_^ or X_X)
    • Redirections handled : >, <, << and >>
    • Pipes |
    • Logical operators && and ||
    • Backquotes "‘" (TODO)
    • Ihibitors """ (double quote), "’" (simple quote) et "" (backslash).
    • ;
    • \n handling where \n can be used as a ;. Example: ls \n ls == ls ; ls
  • Prompt

    • Multi line editing with \, ' and "
    • History handles the multi-line editing
  • Shell

    • This shell proposes multiple options to enhance user experience
    • h This option will display help for all options as described here
    • v Verbose mode
    • d Debug mode (Enables the logger). A log file will be created where the binary exists. This option requires a log level from 0 to 7
    • t Test mode. This mode will test the module X with Y parameter as follows : -t X Y. Can be used with modules env ast parser lexer ast
    • c Command. Use this option to send a command to the shell and get it's output
    • C Color. Use this option to enable color in the shell
    • l Disables the termcaps. This is a debug option and not a feature ! To be used lightly
  • Signals

    • We kill all childs when we get a signal that kills the program so no zombie process is left behind
  • Autocompletion

    • Dynamic autocompletion
    • Autocompletes binaries from PATH
    • Autocompletes files and paths
    • Autorefreshing with a new input from the user: modification of the list of possibility. TODO WIP
    • Known bug: Autocompletion displays the full path (see #124)
    • Known bug: Autocompletion doesnt expand ~ or $.
  • Environ

    • Local Variables are available
    • Normal environment is used when the shell is started
    • Uses the = syntax (VAR=VALUE)
    • Default env is given when 21sh-42sh is started with env -i (TODO to be customized)
    • Message to warn the User when 21sh-42sh is started without an env
  • Bonuses

    • Heredocs "<<".
    • File descriptors aggregation
  • Structure

    • Init
    • Input
    • Lexer
    • Parser
    • Expand
    • Ast
    • Execution
  • History

    • A menu is printed when the history fil is to big
    • The history is printed in the log when exiting the program
    • History research ctrl+R.
  • Tests: 21sh-42sh contains automated tests found in the tests/ folder (See here)

    • Tests for the lexer
    • Tests for the parser
    • Tests for the ast
    • Tests for the expand
    • Tests for the exec
    • Tests for the builtins
    • Tests for the env
    • Tests for the local vars
  • Miscellaneous

    • Logger
    • Doc

The output of cloc (Count Lines Of Code) as of 21/12/2017 22h30:

        465 text files.
        449 unique files.
         48 files ignored.
   
   http://cloc.sourceforge.net v 1.60  T=15.82 s (26.4 files/s, 1756.4 lines/s)
   --------------------------------------------------------------------------------
   Language                      files          blank        comment           code
   --------------------------------------------------------------------------------
   C                               321           2005           6128          12895
   C/C++ Header                     63            713           2244           1644
   Bourne Shell                     25            161             80            794
   make                              3            132            111            374
   CMake                             3             38              5            336
   Bourne Again Shell                1             16              4             61
   YAML                              1             10              0             33
   --------------------------------------------------------------------------------
   SUM:                            417           3075           8572          16137
   --------------------------------------------------------------------------------

About

21sh-42sh is a Linux CLI (Command Line Interface) thought, designed, and made by chbravo-, gpouyat, jlasne and mleroy for the 42 school as the last project before their first internship.

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages