代写 C++ C shell CSE 325

CSE 325
Assignment Overview
Fall 2019
Computer Project #4
For this assignment, you are to design and implement a C/C++ program that will serve as a basic command-line interpreter (shell). You will design and implement additional functionality in subsequent projects.
It is worth 40 points (4% of course grade) and must be completed no later than 11:59 PM on Thursday, 9/26.
Assignment Deliverables
The deliverables for this assignment are the following files: proj04.makefile – the makefile which produces proj04
proj04.student.c – the source code file for your solution
Be sure to use the specified file names and to submit your files for grading via the CSE Handin system before the
project deadline.
Assignment Specifications
1. The program will repeatedly display a prompt containing the sequence number of the current command (starting at 1) and the username of the user executing the program. This information will be enclosed in the characters ‘[‘ and ‘]’. For example:
[1 mccullen]
The sequence number and username will be separated by a single space.
2. After displaying the prompt, the program will repeatedly read one line of input from the user and process it. An input line is defined as a sequence of zero or more tokens (character strings), separated by one or more delimiters (blanks and tabs), ending with a newline character. There will be no more than 128 characters in a line.
If the first token is the name of a built-in command (listed below), then the program will take the appropriate action. Otherwise, the program will assume that it is an error.
3. The program will recognize the following built-in commands:
halt terminate the shell process
help display built-in commands
date display current date and time
env display environment variables
path display current search path
cwd display absolute pathname of current working directory cd manage current working directory
Built-in commands will be completely processed by the program (the program will not create a child process to perform the processing).
4. The command “help” will display a list of all valid built-in commands.

5. The command “date” will display the current date and time in a human-readable format.
6. The command “env” will display the user’s environment variables in a format similar to “setenv” in the C shell. 7. The command “path” will display the current search path in a readable format.
8. The command “cwd” will display the absolute pathname of the current working directory.
9. The command “cd” will manage the current working directory.
a) The command “cd” without any other tokens will reset the current working directory to be the user’s home directory.
b) The command “cd DIR” will reset the current working directory to be “DIR”, where that token may be a relative or absolute pathname.
c) The command “cd ~USER” will reset the current working directory to be the home directory of the user with username USER. As a special case, the symbol “~” represents the home directory of the current user.
10. The program will perform appropriate error handling. It will display an appropriate message if the user’s command fails in any way.
Assignment Notes
1. As stated above, your source code file will be named “proj04.student.c”; that source code file may contain C or C++ statements.
2. You must use “g++” to translate your source code file in the CSE Linux environment.
3. Information about system calls and library functions which might be useful for this project may be viewed using the “man” utility. For example:
man 2 time
man 2 chdir
man 3 ctime
man 3 getcwd
man 3 cuserid
man 3 string
4. As noted above, you will extend your program in subsequent projects, so you would be wise to properly structure and comment your source code.