Seashell is a UNIX shell written in C.
- Seashell can read and execute simple user commands:
Cli>/bin/ls
Cli>ls
- Also, it can interpret a command with arguments:
Cli>ls -l -a
- The commands can be combined in a pipe line (forward output to the next command):
Cli>ls -l -a | grep main
- And can handle pipe line, globing and separator:
Cli>ls -l -a | grep a | wc -l ; ls * ; echo 1
...
Clone the project to retrieve the sources:
$>git clone https://github.com/adugast/seashell.git
Go in the build directory of seashell:
$>cd seashell/build/
Build the project using CMake (from the build directory):
$>cmake ..
Finally, use make to compile the sources and so generate the binary (still from the build directory):
$>make
Launch seashell:
$>./seashell
Cli>ls -l -a | grep a | wc -l
11
Cli>nproc
8
Cli>uname -r
3.10.0-327.10.1.el7.x86_64
Cli>ps
PID TTY TIME CMD
8445 pts/56 00:00:00 bash
11615 pts/56 00:00:00 seashell
11616 pts/56 00:00:00 ps
Cli>
Cli>exit
Usage: ./seashell [params]
Available params:
-h, --help : Display this help and exit
-v, --version : Show version information
-f, --features : Show seashell features
Cursor motion:
- Left, Right Arrows : Move into command line
- Up, Down Arrows : Brows through commands history
Control keys:
- CTRL^L : Clear the screen
- CTRL^A : Move to the start of the line
- CTRL^E : Move to the end of the line
Command parsing:
- Separators: ;
- Globing: * ? [] {}
- Multipipes
- ...
- Alias
- Redirections: < > >>
- Separators: && ||
- Autocompletion
- History whith file
- Builtins: cd, echo, exit, ...
- Job control
+----------------------------+
|Processing of the user input|
+----------------------------+
+----------+
|user input| -IN- user keyboard
+----+-----+
| A read function call is used to get input from STDIN
| and generates a buffer with RAW data.
v (contains printable and special characters)
+---+--+
|buffer| (main interpret function)
+---+--+
| Special characters are directly proceed to handle terminal
| management (i.e arrow keys, ctrl keys, delete, backspace, etc ...)
| and a new buffer line with only printable characters is reconstructed
v <-^
+--+-+ | |
|line| | | (main loop - read keyboard function)
+--+-+ | |
| v-> After pressing "enter", the buffer line goes to the execution module
| and becomes the command line to execute.
v (i.e "ls -l -a | grep a | wc -l ; ls * ; echo 42")
+---+----+
|cmd line| (execution module)
+--------+
Then the command line is parsed by the parser module for each
";", "|" and " " characters and executed.
";" commands separator
"|" split the commands to be executed in a pipeline (output of the executed command is transferred as input for the following command)
" " split the command with their own arguments
- Terminfo and Termcap - Introduction to terminal capabilities and database
- man (5) terminfo - Terminal capability database
- ANSI Escape Sequences - Keycode management
- ASCII Flow - Simple web based ascii flow diagram drawing tool
This project is licensed under the MIT License - see the LICENSE file for details