In this assignment you are to implement a basic shell. A shell is a command line interpreter that accepts input from the user and executes programs on behalf of the user based on the commands that the user inputs. The line that the user enters commands on is referred to as the command line. The shell repeatedly prints a prompt on the command line, waits for the user to enter commands and executes programs. You are to write a simple Unix-like shell in the C programming language that has these features:

  • If your name is xyz then the prompt should be the string xyz>
  • Your shell must support I/O redirection. This includes supporting both input and output redirection in the same command i.e., you should be able to support the following: sort < f1.txt > f2.txt
  • Your shell must support up to two pipes.
  • You do not have to support a command that has both I/O redirection and pipes.
  • A built-in command is a command that changes the state of the shell or requests information about the shell’s state. You should support the following two built-in commands:
    • exit: This command is used to terminate the shell.
    • history: This command is used to print a list of the last 10 commands issued; If there are fewer then 10 commands then print out all previously issued commands.
  • When the user types Ctrl-C the shell should execute the history command.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.