A lightweight, functional Unix shell written in C. This project demonstrates core systems programming concepts, including process lifecycle management, inter-process communication (IPC), and low-level file descriptor manipulation.
- Process Execution: Supports running any external Linux binary by leveraging
fork()andexecvp(). - I/O Redirection: Implements output redirection (
>) by manipulating file descriptors withdup2(). - Command Piping: Supports inter-process communication via pipes (
|), allowing the output of one process to serve as the input for another. - Built-in Commands: Native support for
cd(Change Directory),help, andexitto manage the shell environment. - Robust Error Handling: Custom error reporting using
perrorfor system call failures.
The shell operates on a REPL (Read-Eval-Print Loop) architecture:
- Tokenization: User input is parsed into a null-terminated array of strings using
strtok. - Process Management: For external commands, the shell creates a child process. The parent process synchronizes using
wait()orwaitpid(). - Pipe Implementation: When a pipe is detected, the shell initializes a kernel buffer via
pipe(), forks two concurrent child processes, and reassigns their standard streams.
- GCC Compiler
- Linux Environment (tested on Linux Mint/Ubuntu)
-
Clone the repository:
git clone [https://github.com/AT95BL/At95-Shell.git](https://github.com/AT95BL/At95-Shell.git)
-
Compile the source code: gcc shell.c -o shell
-
Run the shell: ./shell