Homework 8: Dash-ing trough some tasks.
Modify the dash shell to execute programs.
This homework is worth 15 points.
Goals
When you finish this homework you should:
- Worked with fork, exec and wait
- Worked with dup
Assignment
Continue to work the dash shell. Add the following features
- Execute a process. If the user enters a command other than a dash built-in, your shell should attempt to locate and execute the corresponding program.
- Use the environment variable DASH_PATH which is a colon separated list of directories to locate executable with the given name.
- For each directory named in DASH_PATH check to see if an executable file matching the command is given. If so execute that process.
- DASH_PATH should provide the search order for your shell. The first directory listed should be searched first.
- If a command is not found, print a corresponding error message.
- Do not attempt to execute files with a matching name that are not executable for the user.
- Allow processes to be executed with command line arguments.
- Any arguments not consumed by dash ( &, < file , > file) should be passed along to the process.
- The current environment should be passed along to the process.
- Allow processes to be executed in the background
- Under normal operation the shell should wait until the child exits before returning the prompt.
- if the final argument is an & the process should be started and the shell should not wait.
- The shell should keep a list of processes running in the background
- Add a dash build-in command TASKS which prints a list of background jobs.
- This should include:
- The process ID
- The name of the command.
- Allow a process to redirect input and output.
- If a command string contains <, the user would like the next argument (if it exists) to be used in place of standard in.
- If a command string contains >, the user would like the next argument to be used in place of standard out.
- If the redirect symbol is not followed by an additional argument, dash should print an error.
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.