rshell imitates the functionality of a bash terminal. rshell performs the following steps:
- Prints the command prompt with the user's username
<userName>@<hostName> $ - Read in a command(s) on one line. Commands can be separated by connectors.
- Arguements are separated by spaces.
- Connectors include
;,&&,||, and#. - Able to mix and match connectors and commands and still logically work.
- Execute the line of commands
- If a command is followed by
;, then the next command is always executed. - If a command is followed by
&&, then the next command is executed only if the first one succeeds. - If a command is followed by
||, then the next command is executed only if the first one does not succeed. - Anything found after the first found
#is considered a comment will not be passed through the terminal.
- If a command is followed by
- Allows the user to utilize the 'test' command to see if a directory exists or not.
- The 'test' command could be tested in 2 ways:
test -flag test/file/pathOR[ -flag test/file/path ]. - The user is allowed to use one of three flags:
-e,-f,-d. - The
-eflag will be used by default if none are defined. - If a directory exists the terminal will output
(True). - If a directory is not found/doesn't exist, the ternimal will output
(False).
- The 'test' command could be tested in 2 ways:
- The user may use precedence parameters
( )These parameters are used to change the precedence of returns of commands, connectors, and chains of connectors.- Ex)
echo A && echo B || echo C && echo Dwill output: ABD- However, the parenthesis may change the precedence of these commands.
- Ex)
(echo A && echo B) || (echo C && echo D)will output: AB
- Ex)
- cd: This alone other built-in bash commands will not work due to the fact that they have no executable file in the bin
- exit: Sometimes requires to be input 2-4 times. Functionality works, just this bug was observed enough times
- &&: Sometimes when and || is based in the sequence false || true && , and && after this do not get run.
- echo: when doing echo "[connectot]" nothing is output, echo " [anything else]" works as expected
- Massive sequences of || (5>) with all except last returning false will return the last || as false in cases
- Error comes up on first input in the command line. Works fine after that
- cd: This alone other built-in bash commands will not work due to the fact that they have no executable file in the bin
- echo: when doing echo "[connectot]" nothing is output, echo " [anything else]" works as expected
- Seg fault may occur if # is put in multiple ().
- &&: Sometimes when and || is based in the sequence false || true && , and && after this do not get run.
- Multi exit VERY unlikely
$ git clone https://github.com/samhwangg/rshell.git
$ cd rshell
$ git checkout hw2
$ make
$ bin/rshell