System programming | Computer Science homework help

BACKGROUND: A shell provides a command-line interface for users. It interprets user commands and executes them. Some shells provide simple scripting terms, such as if or while, and allow users to make a program that facilitates their computing environment. Under the hood, a shell is just another user program as you know from Minor2 assignment. The file /bin/bash is an executable program file for the bash shell. The only thing special about your login shell is that it is listed in your login record so that /bin/login (i.e., the program that prompts you for your password) knows what program to start when you log in. If you run “cat /etc/passwd”, you will see the login records of the machine.


GROUP COLLABORATIVE PORTION: In this assignment, you will implement the shell “engine” as the group component, where all members are responsible for the following functionality.

A Command-Line Interpreter, or Shell

Your shell should read the line from standard input (i.e., interactive mode) or a file (i.e., batch mode), parse the line with command and arguments, execute the command with arguments, and then prompt for more input (i.e., the shell prompt) when it has finished. This is what Minor 2 program should do with addition of batch processing which means just reading a batch line by line and calling the same interpretation logic.

  1. Batch Mode

In batch mode, your shell is started by specifying a batch file on its command line. The batch file contains the list of commands that should be executed. In batch mode, you should not display a prompt, but you should echo each line you read from the batch file back to the user before executing it. After a batch is finished the shell will exit.

  1. Interactive Mode

No parameters specified on command line when the shell is started. In this mode, you will display a prompt (any string of your choice) and the user of the shell will type in a command at the prompt.

You will need to use the fork() and exec() family of system calls. You may not use the system() system call as it simply invokes the system’s /bin/bash shell to do all of the work. You may assume that arguments are separated by whitespace. You do not have to deal with special characters such as ‘, “, , etc. You may assume that the command-line a user types is no longer than 512 bytes (including the ‘n’), but you should not assume that there is any restriction on the number of arguments to a given command.


Build-in Commands: Every shell needs to support a number of built-in commands, which are functions in the shell itself, not external programs. Shells directly make system calls to execute built-in commands, instead of forking a child process to handle them.

In this assignment, each member of the group will implement one of the following section and commit in GitLab the code that supports those commands:

  1. Add a new built-in alias command that allows you to define a shortcut for commands by essentially defining a new command that substitutes a given string for some command, perhaps with various flags/options. The syntax is as follows: alias alias_name=”command”. For example, you can define an alias with alias ll=”ls –al”, so that the user can then enter ll at the prompt to execute the ls -al command. Specifying alias with no arguments should display a list of all existing aliases. You may remove a single alias with the command alias -r alias_name or all defined aliases with alias -c.
  2. Add a new built-in exit command that exits from your shell with the exit() system call. Also add support for signal handling and terminal control (Ctrl-C, Ctrl-Z). You do not want those signals to terminate your shell. Instead you need to handle them and terminate processes that your shell started if any. Be aware that forked processes will inherit the signal handlers of the original process.
  3. Add a new built-in path command that allows users to show the current pathname list. The initial value of path within your shell will be the pathname list contained in the PATH environment variable. path + ./dir appends the ./dir to the path variable. You may assume that only one pathname is added at a time. You will need to add it to the “real” PATH environment variable for executables in the path to work correctly. path – ./dir removes the pathname from the path variable. You may assume that only one pathname is removed at a time. Also, you need to restore your PATH environment variable to its original state when the user exits your shell.
  4. Add a new built-in history command that lists your shell history of previous commands. It is up to you to select what number of prior commands to keep in history. history –c command should clear your history list. history N, where N is number, displays your prior N-th command starting with the last one. history N -e executes your prior N-th command.

OPTIONAL assignments for extra credits:

  1. Extend your shell with I/O redirection: <, >, >> (+20%).
  2. Extend your shell with pipelining | (+20%).

DEFENSIVE PROGRAMMING (GROUP COLLABORATIVE EFFORT): Check the return values of all system calls utilizing system resources. Do not blindly assume all requests for memory will succeed and that all writes to a file will occur correctly. Your code should handle errors properly. In general, there should be no circumstances in which your C program will core dump, hang indefinitely, or prematurely terminate. Therefore, your program must respond to all input by printing a meaningful error message and either continue processing or exit, depending upon the situation. Many questions about functions and system behavior can be found in the manual pages. You should handle the following situations:

  • An incorrect number of command line arguments to your shell program;
  • The batch file does not exist or cannot be opened.
  • A command does not exist or cannot be executed.
  • A very long command line (over 512 characters including the ‘n’).

REQUIREMENTS: Your code must be written in C.

GRADING: Your C program file(s), README, and makefile shall be committed to our GitLab environment as follows:

  • Your C program file(s). Your code should be well documented in terms of comments. For example, good comments in general consist of a header (with your name, course section, date, and brief description), comments for each variable, and commented blocks of code.
  • A README file with some basic documentation about your code. This file should contain the following four components:

Your name(s);

Organization of the Project. Since there are multiple components in this project, you will describe how the work was organized and managed, including which team members were responsible for what components – there are lots of ways to do this, so your team needs to come up with the best way that works based on your team’s strengths. Note that this may be used in assessment of grades for this project.

Design Overview: A few paragraphs describing the overall structure of your code and any important structures.

Known Bugs or Problems: A list of any features that you did not implement or that you know are not working correctly.

  • A Makefile for compiling your source code, including a clean directive.
  • Your program will be graded based largely on whether it works correctly on the CSE machines.
University Writings
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.


Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.


Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.


Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.


Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.