This first version of the shell won't actually be an interactive
program. Instead, ouch will execute a "sub-command" that the
user enters on the ouch command line following a -c
command line option.
For example, the following would be a valid invocation of ouch:
% ouch -c ls -lIn this example, the '%' is the user's shell's prompt, ouch is the name of the command, -c is the -c command line option, and the sub-command to be executed is "ls -l".
If the user enters any option other than "-c" or omits the "-c" before the sub-command line, it is an error, and your program is to print an error message showing proper invocation syntax, and exit. However, if the user gives no command line arguments at all, the program is to exit normally, with no error message.
Your program must be coded according to the [ Coding Guidelines ] for this course. This includes the requirement that the program must compile and link with no error or warning messages, in addition to running correctly. It also includes the requirement that the program must be properly documented.
You are to use RCS to manage the files in this project. For this assignment, that means the files named Makefile and ouch.cc. Be sure both files contain proper $Id$ and $Log$ RCS macros in appropriate places. (See the Coding Guidelines if in doubt.)
Because the project uses only a single source module,
ouch.cc
, there is no need for a make rule for
building the executable file, ouch. Thus, in addition to
comments and variable definitions, the Makefile for the assignment is
to include only a rule for the target "clean" like the following:
clean : <tab> rcsclean <tab> rm -f core ouch
ouch.cc
, which you are to compile into an executable file
named ouch
using the following command line:
make ouchThe above command must be expanded by make to the following command, which must produce no warning or error messages:
g++ -g -Wall -Wwrite-strings ouch.cc -o ouchThis example assumes that
ouch.cc
is already in the
project directory. If it and the Makefile are absent, make will
check them out first, and remove ouch.cc at the end.Note that the following variables must be defined either in your Makefile or in your environment:
CC = g++ CXXFLAGS = -g -Wall -Wwrite-stringsWhen I test your program, they will both be defined in my environment.
getopt() | To process command line options. |
perror() | To print any error messages due to system call failures. |
fprintf() | To print error messages to stderr, other than the ones that perror() handles. |
getenv() | To get the value of the PATH environment variable. |
strtok() | To divide the value of the PATH environment variable into a list of directories. |
stat() getuid() getgid() | To determine if a file exists, and if the user has permission to execute it. |
execve() | To execute the file. |
Create a clean project directory (a directory containing only the RCS subdirectory, with Makefile,v and ouch.cc,v in the RCS subdirectory under RCS control), put the project directory into a tar file, and send the tar file to me as an email attachment by midnight October 18. Note: when I extract the contents of your tar file, I should get a subdirectory under the current directory for your project directory, and an RCS subdirectory under that.
Be sure the Subject line of your email message says, "CS-701 Assignment 3."