Design Shell Interpreter in Linux or Unix
Design Shell Interpreter in Linux or Unix
Design Shell
Interpreter in
Linux or Unix.
1
Click to edit Master title style
Credit:
Rajat Kumar (43)
Aditya Mritunjay(52)
Divya Nand (53)
Mukul Lakhani (47)
Aditya Mishra (51)
2 2
UnixtoShell
Click edit Master title style
3 3
Overview
Click to edit Master title style
Whenever your shell accepts a command, it should check whether the command
is a built-in command or not. If it is, it should not be executed like other programs.
Instead, your shell will invoke your implementation of the built-in command. For
example, to implement the exit built-in command, you simply call exit(0); in your
dash source code, which then will exit the shell. In this project, you should
implement exit, cd, and path as built-in commands. exit: When the user types
exit, your shell should simply call the exit system call with 0 as a parameter. It is
an error to pass any arguments to exit. cd: cd always take one argument (0 or
>1 args should be signaled as an error). To change directories, use the
chdir()system call with the argument supplied by the user; if chdir fails, that is also
an error. path: The path command takes 0 or more arguments, with each
argument separated by whitespace from the others. A typical usage would be like
this: dash> path /bin /usr/bin, which would add /bin and /usr/bin to the search path
of the shell. If the user sets path to be empty, then the shell should not be able to
run any programs (except built-in commands). The path command always
6 6
overwrites the old path with the newly specified path.
Program
Click to editErrors
Master title style
The one and only error message. You should print this one and
only error message whenever you encounter an error of any
type: The error message should be printed to stderr (standard
error), as shown above. After most errors, your shell simply
continue processing after printing the one and only error
message. However, if the shell is invoked with more than one
file, or if the shell is passed a bad batch file, it should exit by
calling exit(1). There is a difference between errors that your
shell catches and those that the program catches. Your shell
should catch all the syntax errors specified in this project page. If
the syntax of the command looks perfect, you simply run the
specified program. If there are any program-related errors (e.g.,
invalid arguments to ls when you run it, for example), the shell
7 7
does not have to worry about that (rather, the program will print
Click to edit Master title style
Thank You