In this lab, your team will start with the
program from Figure 7.6 (p. 229) and progressively move it closer to
the features of a realistic shell. (Perhaps you might call your
program minishell, given its relative size and complexity.) You
should turn in the final working version you wind up with. If you
have made some progress toward a further revision, but not gotten it
working, you can turn it in as well with an explanation of what is
wrong with it.
Start by doing Programming Project 7.3. In learning the relevant
aspects of the C++ standard library, you may find the following sample
words3.cpp. The approach
illustrated by these examples isn't the only viable one; C++'s
standard library is rich enough that there are plenty of other
approaches. If you are comfortable with some other approach, feel
free to use it.
Next, do Programming Project 7.4. For simplicity, you may assume
& character is a word on its own, that is,
separated from whatever precedes it using whitespace. Also, you may
initially ignore the potential for zombies.
program from Figure 8.2 (p. 277) illustrates how the
operator within a shell redirects standard output. Add this feature
into your shell; for simplicity, you can assume that the
> operator is a separate whitepace-delimited word in
the input. You might also restrict the position of the output
redirection, limiting it to be at the end (except for a possible
Add input redirection similarly.
At this point, you have a basic shell and can start making improvements. A high priority for me would be putting in the code to clean up zombies. But you might also want to make the input syntax more flexible, and you might want to add additional features that you are familiar with from real shells.