Project 4 - Simple Bash

Computer Architecture I   ShanghaiTech University
Project 3   Project 4  

Bash

The Bash is a command processor that runs in most Linux distributions. It is the default login shell of Ubuntu and Solaris. This command processor can parse the commands that user type in the text window and execute them. Except running in text window, Bash can also parse shell script which contains commands in a file. In this project, we are going to implement a simple Bash in C.

Requirement

The input of your implemented simple bash will be a shell script by redirection (such as shell test.sh) or by manual input. The simple bash needs to behave the same as bash in Ubuntu. We will check your implementation by manual input and by redirecting your output to a text file (such as shell test.sh > output.txt). Therefore, you need to pay attention to different output formats. For example, try typping ls in text window and ls > output.txt.

The following functions are likely to be helpful: fork, exec, execvp, wait, waitpid, kill, dup, pipe, strncmp, strlen, malloc, free, getcwd, chdir , open, close, readline, gets, fgets, getchar, signal, getpwuid, gethostname (NO system!!!)

You are going to implement following stuff:

Submission and Grading

We will be using git for this project as well. Refer to previous Git Usage Guide for basic git usage. Create your team's git repo for Project 4 on GitHub, initialize your framework directory as a git repository (which means it directly contains shell.c, parse.c, parse.h, Makefile), and push your work onto your remote repository. Submit your work to Autolab with an archive project4.tar, which is created through:

  git clone --bare YOUR-TEAM-REPO-URL.git .git
  tar czvf project4.tar .git

The structure of your git repository should be the same as below, where parse.c and parse.h contain the code for parsing the command, shell.c contains the code for executing the command. The Makefile should produce an executable file shell for evaluation.

YOUR_GIT_REPO
  |- shell.c
  |- parse.c
  |- parse.h
  |- Makefile

We will compare the behavior of your shell with bash under Ubuntu 16.04. We will test the output of your shell using redirection.