Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Coding Requirements Write a command shell called rshell. Your shell will perform

ID: 3759676 • Letter: C

Question

Coding Requirements Write a command shell called rshell. Your shell will perform the following steps: 1. Print a command prompt (e.g. $) 2. Read in a command on one line. Commands will have the form: cmd = executable [ argumentList ] [ connector cmd ] connector = || or && or ; where executable is an executable program in the PATH and argumentList is a list of zero or more arguments separated by spaces. The connector is an optional way you can run multiple commands at once. 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 fails. For example: $ ls - a $ echo hello $ mkdir test is equivalent to: $ ls - a; echo hello; mkdir test There should be no limit to the number of commands that can be chained together using these operators, and your program must be able to handle any combination of operators. For example, you should be able to handle the command: $ ls - a; echo hello && mkdir test || echo world; git status 1. Execute the command. This will require using the syscalls fork, execvp, and waitpid. Previous cs100 students created two video tutorials (a fun cartoon tutorial ; more serious explanation). You should also refer to the man pages for detailed instructions. 2. You must have a special built - in command of exit which exits your shell. 3. Anything that appears after a # character should be considered a comment. For example, in the command is - lR /, you would execute the program /bin/ls passing into it the parameters - lR and /. But in the command is # - lR /, you would execute /bin/ls, but you would not pass any parameters because they appear in the comment section.

Explanation / Answer

To open terminal -

1. press ctrl+alt+T

2. go to application->accessories->terminal

$ echo "hello, $LOGNAME";

echo 'date' && echo "current directory 'pwd'"

exist