This project involves building a custom shell in C, focusing on modular programming and encompassing a variety of shell functionalities such as system calls, command parsing, file and directory operations, process management, and networking.
- Implementation: Divides the codebase into multiple C files, each dedicated to specific functionalities, enhancing code readability, maintainability, and scalability.
- Implementation: Executes system commands in both foreground (waiting for completion) and background (allowing concurrent execution).
- Implementation: Parses commands separated by ';' (sequential execution) or '&' (background execution), involving input string tokenization.
- Implementation: Changes the current working directory with support for relative, absolute paths, and special flags (".", "..", "~"), using system calls like
chdir
.
- Implementation: Lists files and directories with options for hidden files (
-a
) and detailed information (-l
), using system calls likeopendir
andreaddir
.
- Implementation: Stores and retrieves recent commands, maintaining a history buffer and excluding redundant entries like
pastevents
itself.
- Implementation: Manages foreground and background processes, including custom commands for process information (
proclore
) and control (fg
,bg
), using system calls and signal handling.
- Implementation: Supports redirection (
>
,>>
,<
) and piping (|
) between commands, involving file descriptor manipulation and pipe creation.
- Implementation: Fetches manual pages from the internet using TCP sockets, HTTP requests, and response parsing.
- Error Handling: Robust error handling to prevent crashes, checking system call return values and handling exceptions.
- User Interface: User-friendly interface with color coding and clear error messages.
- Assumptions: Simplifies implementation by assuming no whitespace in paths/names and no background processing for user-defined commands.
- Clone the repository.
- Use the provided
makefile
to compile the code. - Run
./a.out
to start the shell.
- Execute system or custom commands like
warp
,peek
,pastevents
. - Use
;
or&
to separate multiple commands. - Navigate directories, list files, manage processes, and more.
Contributions to improve the shell or add new features are welcome. Please maintain the modular structure of the code.
This project is distributed under the MIT License.
Arjun Dosajh