Homework 7 Starting the DASH

Begin constructing a shell.

This homework is worth 20 points.

Goals

When you finish this homework you should:

Assignment

This project is the beginning of a series of assignments aimed at constructing DAn's SHell or dash. The purpose of this shell is to experiment with the concepts we have discussed. We will be adding to this so you need to keep your code open and flex able.

This shell will be line oriented. The basic loop will be

while not done
      read a line (command)
      process the line
Parsing the command line is your first challenge. There are many ways you could accomplish this task. In some sense it depends on what you know and how much time you wish to invest in this portion of the project.. We will be parsing input in the following form:
     command: cmd  | cmd redirectl | cmd pipe cmd |  builtin
     cmd: STRING args 
     args : STRING | STRING argl | ε
     pipe: "|"
     redirectl: redirect | redirect redirectl
     redirect: < STRING | > STRING  | ε
     builtin: buitin_s | builtin_a 
     builtin_s: "UID" | "PID" | "PPID" | "NAME" | "WD" | "INFO" | "EXIT" | "UP" | "HOME" | "HD" 
     builtin_a: prompt | run | down | go | set
     prompt: "PROMPT" INTEGER
     run: "RUN" STRING
     down: "DOWN" STRING
     go: "GO" STRING 
     set: "SET" STRING STRING
Note: the grammar above may contain errors and is most certainly incomplete.

For now, you need to deal with the following built in commands:

The integer associated with prompt determines how the prompt is displayed. Treat this integer as a set of bit flags, and display the following
Value Value to Display
0 ">"
1 Environment variable PROMPT
2 Current directory basename
4 The first part of the host name (up to the first .)
8 username
These are displayed in descending order. The delimiter between portions is :.Assume that the machine is Mirkwood, the current directory is foo and the user name is bennett, and the environment variable PROMPT is "%". The following prompts would be :
n Prompt
0 >
1 %
2 foo
3 foo:%
5 Mirkwood:%
15 bennett:Mirkwood:foo:%
I will not be adding any features to the prompt, so you may embellish on this if you wish.

Your program should recognize the following command line arguments when it is started.

Discussion

Submission

Email a copy of the C code to complete the final task to your instructor by class time. If your code consists of a single file, the source code will be sufficient, if the code is in multiple files, you should submit a tar file containing the source code and a make configuration file required to build the project.