A simple shell program (msh) implemented in C that mimics the behavior of the BASH shell. This project is built using Linux Kernel system calls and IPC mechanisms.
-
Prompt Customization:
- Default prompt:
msh > - Can be customized using the
PS1environment variable (e.g.,PS1=NEW_PROMPT). - Prevents spaces between
=(e.g.,PS1 = NEW_PROMPTis treated as a normal command).
- Default prompt:
-
Command Execution:
- Executes both internal and external commands.
- Creates a child process for external commands, waits for its completion before displaying the prompt again.
-
Special Variables:
echo $?: Prints the exit status of the last executed command.echo $$: Prints the PID of themshprocess.echo $SHELL: Prints the executable path of themshprogram.
-
Signal Handling:
Ctrl+C: SendsSIGINTto the foreground program. If no program is running, it redisplays the prompt.Ctrl+Z: SendsSIGTSTPto the foreground program and displays its PID.
-
Built-in Commands:
exit: Terminates themshprogram.cd: Changes the working directory.pwd: Displays the current working directory.
- Linux OS
- GCC compiler
- Clone the repository:
git clone https://github.com/your-username/msh.git cd msh