Skip to content

toberge/nessie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ne[sh]ie

Integration tests Fuzzer tests

The absurdly stupid shell

Minimal shell written in C as a hobby project.

Demo session

Features

  • Fork and execute commands
  • cd with builtin or by typing a folder name
  • Piping
  • Multiple statements terminated by ;
  • Conditional execution with && and ||
  • History (as builtin)
  • Comments
  • Script files (including stdin)
  • Variables
  • Some keybinds (requires raw mode + rework of input code)

Requirements

Nessie depends on nothing but the tools required to build it – make and a C compiler – and some regular Linux syscalls.

Running the tests requires bats and/or clang.

Producing the man page requires pandoc – this is only done in the make install target.

Installation

Run make install or make install-local. Alternatively, simply run make and put the binary wherever you want.

You should now be able to execute nessie as a regular command, or run the binary with ./nessie.

Testing

Run integration tests with make test or fuzzer tests with make fuzz.

Usage

Start an interactive session by simply running nessie. If you are stuck, try running help, man nessie or man <some other command>.

Run a single command with nessie -c "some command".

Execute a script file with nessie script.sh. One can also pipe or otherwise redirect a list of commands to nessie, like echo "some command" | nessie.

See the manual page for a more thorough explanation of Nessie's functionality.

Grammar

Nessie's grammar is pretty minimal for the time being.

LINE      := STATEMENT [; STATEMENT]* [# COMMENT]
STATEMENT := COMMAND
           | COMMAND && STATEMENT
           | COMMAND || STATEMENT
COMMAND   := PROG [ARG]* [| COMMAND]*
PROG, ARG := TOKEN
           | "TOKEN [TOKEN]*"
           | 'WORD [WORD]*'
TOKEN     := VARIABLE
           | WORD
VARIABLE  := $[A-Za-z0-9]+
WORD      := <just continuous text>
COMMENT   := <any text following a #>

Resources used

  • Linux manual pages for various C functions
  • The C Programming Language by Brian W. Kernighan and Dennis M. Ritchie
  • This stackoverflow answer to a question about piping in C