SCOTSHELL - A Project Terminal

csscot.jpg

INTRO

Scottshell is a basic Linux shell that takes in a built-in commands along with some extras such as AND, OR, SEMICOLON, TESTCOMMANDS, and INPUT/OUTPUT REDIRECT/APPEND. Using a composite pattern approach, I’ve created inheritance hierarchy that will allow my composite classes functionality to be inherited in this manner.

DIAGRAM

UMLDIAGRAM.jpg

CLASSES/CLASS GROUPS

class Argument - This is our base class in which all subsequent will inherit from.

virtual bool execute() = 0; //Will be called by all our functions. This will be initiated in the main and return to the main.

virtual void addLeft() = 0; //Some components such as ADD or OR need more than one argument. The semicolon will only have the left.

virtual void addRight() = 0; //As stated above, this gives some of our connectors working functionality.

class CMDPROMPT Parser - Will parse command line for user inputted strings (ALSO TOKENIZES).

ALSO, I ADDED A PARENTHESIS PARSER THAT WAY WE CAN SET PRECEDENCES SUCH AS:

(echo A && echo B) || (echo C && echo D)

will output: A B

NORMALLY, WITHOUT PARENTHESIS, IT WORKS AS SUCH:

echo A && echo B || echo C && echo D

will output: A B D

class ADD, OR, SEMICOLON - Same as Linux Functionality

class TESTCOMMAND - THIS CLASS WILL INHERIT FROM OUR BASE ARGUMENT CLASS AND WILL USE S_ISREG TO CHECK IF IT IS A EXISTING FILE AND ALSO S_ISDIR TO SEE IF IT IS A EXISTING DIRECTORY. OF COURSE THESE WILL RETURN EITHER BOOL VALUES TRUE OR VALSE AS WELL AS OUTPUTTING (TRUE) OR (FALSE). AS FOR THE TEST COMMANDS, TESTING COULD EITHER BE DONE BY DECLARING "test" or simply having a BRACKET.

test -d googletest is equivalent to [ -d googletest ]

OUR PROGRAM SHOULD BE ABLE TO READ THREE FLAGS, -d, -e, and -f.

-e checks if the file/directory exists

-f checks if the file/directory exists and is a regular file

-d checks if the file/directory exists and is a directory

class INPUT/OUTPUT REDIRECT/APPEND AND PIPE

OutputRedirect '>' will output from stream with descriptor redirected to file: cat n > fartfile.txt

Input Redirect '<' will read input from the file: program < fartfile.txt

OutputRedirect '>>' output from stream with descriptor n appended to file: n >> fartfile.txt

Pipe '|' general purpose processing and command chaining tool

RUN COMMAND

git clone https://github.com/CCSDylan/scotshell

ls -a

cd scotshell/

cd src

g++ -std=c++11 Shell.cpp

./a.out

For Google Tests

git clone https://github.com/CCSDylan/scotshell

git submodule init

git submodule update

cmake3 .

make

./test

Technologies used in this project:

C++, Linux, GoogleTest, GitHub

Previous
Previous

P2P to Offload Tasks Between Network VMs

Next
Next

Industrial Network Audit Tool