A UNIX shell I made for CSCI-442 (Operating Systems) in Spring 2016
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
tests
.gitignore
Makefile
README.md

README.md

Shadow Recruit Shell

This shell was made by Jack Rosenthal, more commonly known as Shadow Recruit.

List of all files - with what each does:

./Makefile                      Makefile
./tests                      \  Folder containing programs to test
./tests/alias_test.c          > hashtable, aliasing.
./tests/hashtbl_test.c       /
./bin                           Where the objects appear
./src
./src/alias.c                   Aliasing
./src/alias.h                   Aliasing, header
./src/builtin.c                 Builtins
./src/builtin.h                 Builtins, header
./src/scripting.c               Scripting functionality
./src/scripting.h               Scripting functionality, header
./src/hashtbl.c                 My own hash table implementation
./src/hashtbl.h                 Hashtable, header
./src/compl.c                   Tab completion
./src/compl.h                   Tab completion, header
./src/interact.c                Interactive shell features
./src/interact.h                Interactive shell features, header
./src/core.c                    Core functionality
./src/core.h                    Core, header
./src/main.c                    Main
./pts-clang                     Folder containing portable compiler for
                                this assignment

Extra Features

This shell would be truly incomplete without a list of all of it's extra features. So here is a list:

  • Shell Scripting - Pass the script filename as the first argument to the shell
  • Persistent history - History file is saved in the user's home directory for history the next time the shell is started
  • Read and write files at the same time, so this works: tac < Makefile > elifekaM
  • Token expansion of environment variables - If $ is the first character in an argument, it will expand to it's corresponding environment variable (or local variable, see below)
  • Local variables - Also technically not in the requirements, the syntax varname=value ... as a command will create local variables
  • Export environment variables - Use the export builtin to set environment variables with the syntax export varname=value varname=value ...
  • Destroying shell builtins - destruct shell builtins using the builtin unbuiltin followed by the builtin to destroy. If you don't like this feature, then unbuiltin unbuiltin. Also fun to unbuiltin exit as this will break ^D.
  • Setting multiple aliases at once - Same syntax as bash: alias hello=world goodbye=catvideos ...
  • Viewing a single alias (or specified aliases) values - Same syntax as bash: alias hello goodbye ...
  • Non-word based pipe/file tokenisation - So the following can be valid: date|cat | wc -l>outfile
  • shopt builtin, see below.

A number of features break test compatibility and have to be enabled by using the command shopt bashcompat true. This option makes the shell (slightly) more bash compatible. The features that can be accessed using this command are:

  • pwd with any number of arguments! The rest are ignored.
  • cd... also with extra arguments!
  • Loosey goosey bash pipes - so the following syntax acts the same as it does in bash (touching file1, writing to the pipe, touching file2, appending to file3): cat Makefile > file1 | tac > file2 >> file3
  • A number of other, possibly scary, things.

This shell also keeps track of your internet search history, and if you frequently search for cat videos, will randomly print cute kittens as your shell prompt, however this feature only currently works if you use Bing.

So how much time of my life did I use on this shell?

Approx 15-20 hours, not including the time it took me to write the hash table implementation, as it was not required, but an enjoyable experience for me.