Describe the functionality and design of ish, and the stages of program development
ish: a simple but realistic UNIX shell
Show file sample_ishrc.txt (from the assignment statement)
Contains examples of the kinds of commands that ish must interpret
Line 1: echoExecutable binary commands
Relative path names
Line 2: echo "*** SIMPLE COMMANDS"Command line arguments, double quotes
Line 4: cdShell built-in commands
Line 11: /bin/dateAbsolute path names
Line 14: ls > 217test.1Redirection of stdout
Line 15: cat < 217test.1Redirection of stdin
Line 20: date | wcPipelines containing two commands
Line 21: date | wc | cat | grep 1Pipelines containing more than 2 commands
Line 25: cat < 217test.1 | grep 217test.1Combinations of redirection and pipes
Line 26: cat < 217test.1 | grep 217test.1 > 217test.3Redirection of stdin of first command, and stdout of last command of a pipeline
Line 31: setenv FOO barShell built-in command
Setting of environment variables
(bash uses more complex "export" command
Line 32: printenvExecutable binary command to examine environment variables
Line 33: unsetenv FOOShell built-in command
Unsetting of environment variables
Line 37: notfoundNo such command
Line 38: ls "<" 217test.3Quotes to change special character into an ordinary one
Error: no such file
Another example:
echo one > two echo one ">" twoLine 39: date > 217test.4 | wcError: can redirect stdout of only last command of pipeline
Study the assignment statement for details
Draw diagram on board showing::
Lexical Analysis Phase
Input: a line (i.e. a character sequence)
Output: token list
Syntactic Analysis Phase (i.e. Parser)
Input: token list
Output: pipeline -- a structure containing commands
Execution Phase
Input: pipeline
Output: The execution of the pipeline
Example 1:
Input line:
echo one > myfileToken list:
token 1: echo token 2: one token 3: > token 4: myfilePipeline
command 1: arg 1: echo arg 2: one stdinredirect: NULL stdoutredirect: myfile (other)
Note: Your implementation of pipeline may be different; in particular, it may (eventually) contain more data
Example 2:
Input line:
echo "one two" threeToken list:
token 1: echo token 2: one two token 3: threePipeline:
command 1: arg1: echo arg2: one two arg3: three stdinredirect: NULL stdoutredirect: NULL (other)
Example 3:
Input line:
ls -al | moreToken list:
token 1: ls token 2: -al token 3: | token 4: morePipeline:
command 1: arg 1: ls arg 2: -al stdinredirect: NULL stdoutredirect: NULL (other) command 2: arg 1: more stdinredirect: NULL stdoutredirect: NULL (other)
See the Assignment 6 Development Stages handout
Copyright © 2002 by Robert M. Dondero, Jr