This project is the collaboration between Leyla Khaspoladova and David Abdurahmanov. The Simple Shell is a custom implementation of the Thompson Shell (sh). This command-line interpreter provides a user interface for the Unix operating system. The program reads commands from either the standard input or a file and executes them. This project was developed to explore the depths of system calls, process management (fork, exec, wait), and memory management.
- Dual Execution Modes: Fully functional in both interactive (terminal) and non-interactive (piped) modes.
- Process Management: Utilises the
fork,execve, andwaitsystem calls to manage command execution lifecycles. - Path Resolution: Dynamically handles command execution by searching the
PATHenvironment variable. - Built-in Commands: Support for internal shell commands, including
exitandenv. - Input Handling: Robust command-line tokenization and handling of the End-of-File (
EOF) condition.
The shell is compiled using the following flags to ensure code quality and standard compliance:
gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh- Style: All code adheres to the Betty Style guide for C.
- Memory Management: Zero tolerance for memory leaks; verified through systematic testing via
valgrind. - Modular Design: A strict limit of five functions per source file to ensure maintainability.
- System Interface: Optimised use of system calls to interact directly with the kernel.
| FILE | FUNCTIONALITY |
|---|---|
main.c |
Core logic and the primary execution loop. |
main.h |
Global header containing prototypes and include guards. |
exec.c |
Logic for command execution and process synchronisation. |
args.c |
String parsing, tokenisation, and PATH handling. |
env.c |
Functions for environment variable access and manipulation. |
commands.c |
Implementation of internal shell built-ins. |
man_1_simple_shell |
Comprehensive manual page for the interpreter. |
AUTHORS |
Credit for project contributors. |
$ ./hsh
($) /bin/ls
main.c main.h exec.c hsh
($) exit
$ echo "/bin/ls" | ./hsh
main.c main.h exec.c hsh
Leyla Khaspoladova GitHub: @leyla009