Basic shell wish
works as a command line interpreter (CLI). When a command accepted (in response to its prompt), the shell creates a child process that executes the command just entered and then prompts for more user input when it has finished.
- basic shell
wish
: This is an interactive loop which repeatedly prints a promptwish>
, parses the input, executes the command specified on that line of input, and waits for the command to finish. This is repeated until the user types exit.
Also implement exit
, cd
, history
, and path
as built-in commands.
-
exit
: When the user typesexit
, this shell calls theexit
system call with 0 as a parameter. It is an error to pass any arguments toexit
. -
cd
:cd
takes one argument (0 or >1 args should be signaled as an error). Used thechdir()
system call with the argument supplied by the user to change directories; ifchdir
fails, that is also an error. -
history
: When the user enters thehistory
command with no arguments, then the shell prints a list of all the lines of input which the user has entered since the shell was started including the history command. The user may also supply a single argument to thehistory
commandn
wheren
is a number. When this happens the shell prints the previousn
lines of input (ifn
is not an integer, then its value is rounded up to the next greatest integer).