- Harsh Tamakuwala - ID: 100824220
- Syed Nasir Hussain Naqvi - ID: 100809447
- David Hanna - ID: 100828635
myshell is a basic command-line interpreter designed to replicate fundamental Unix shell functionalities. This README offers comprehensive guidance for users to effectively navigate and utilize myshell.
myshell offers several internal commands:
cd <directory>: Changes the current default directory to<directory>. If<directory>is unspecified, the current directory is displayed. An appropriate error message is shown if<directory>does not exist. This command also updates thePWDenvironment variable.clr: Clears the screen.dir <directory>: Lists the contents of directory<directory>.environ: Displays all environment strings.echo <comment>: Shows<comment>on the display followed by a new line. Multiple spaces/tabs are reduced to a single space.help: Exhibits the user manual using the more filter.pause: Halts operation of the shell until 'Enter' is pressed.quit: Exits the shell.
myshell also supports external commands through the fork and exec method:
- If the command is recognized as an internal command, it is executed directly.
- If it's not an internal command, the shell forks a child process.
- In the child process, the parent environment variable is set using the
setenvfunction. - The external command is then executed using
execvp. - The parent process waits for the child process to finish using
wait(NULL).
Try these commands to explore:
pwd: Displays the current working directory.ls: Lists the contents of the current directory.echo: Prints a message.date: Shows the current date and time.
Additionally, myshell is capable of taking command line input from a file.
To test this functionality:
- Create a simple batch file named
batchfilewith desired commands. - Run the shell in batch mode using:
./myshell batchfile
To install myshell, follow these steps:
- Clone the repository to your local machine.
git clone OS_LAB2-MyShell
- Navigate to the directory containing the source code.
cd myshell - Compile the source code using the provided Makefile.
make
- Run the compiled executable file.
./myshell
myshell supports I/O redirection using the following symbols:
<: Redirects input from a file.>: Redirects output to a file.>>: Appends output to a file.
To exit myshell, simply type the quit command or press Ctrl + C.