RoboShell is a custom-built shell implemented in C++ that mimics the basic functionality of a Unix shell. It allows users to execute system commands, handle redirections, and process commands with pipes, among other features. The project showcases fundamental system programming concepts such as process management, file I/O, and signal handling.
- Command Execution: Run commands like
ls
,pwd
,echo
, etc., if they exist in the$PATH
. - Input/Output Redirection: Redirect standard output to a file using
>
. - Command Chaining: Use
|
to chain multiple commands. - Multiple Commands: Execute multiple commands separated by
;
. - Signal Handling: Gracefully terminate the shell using
Ctrl+C
orCtrl+Z
. - Command Logging: Logs all commands entered during the session to
roboshell_commands.txt
.
fork()
: To create child processes for executing commands.execve()
: To replace the child process image with the desired executable.pipe()
: To create pipes for inter-process communication.dup2()
: To duplicate file descriptors for redirection.open()
/close()
: To handle file operations during redirection.waitpid()
: To manage parent-child process synchronization.kill()
: To handle signals and terminate child processes.getcwd()
: To retrieve the current working directory.chdir()
: To change the current directory.
- Path Resolution:
- Commands must exist in the
$PATH
for execution. Absolute paths are supported, but missing commands result in a "command not found" error.
- Commands must exist in the
- Error Handling:
- Errors are printed to the console but not handled uniformly across all features.
- Input Validation:
- Limited validation for user inputs; incorrect inputs may result in crashes or undefined behavior.
- Signal Handling:
- Signal handling (
Ctrl+C
/Ctrl+Z
) is rudimentary and may not terminate all running background processes properly.
- Signal handling (
- Chaining Commands:
- Complex command chains with multiple redirections or pipes may behave unexpectedly.
- Output Formatting:
- The shell output formatting could be improved to better mimic standard shells.
- Robust Input Parsing:
- Implement a robust tokenizer for better handling of spaces, quotes, and special characters.
- Command Autocompletion:
- Add tab-based autocompletion for commands and file paths.
- Better Error Handling:
- Provide more descriptive error messages and handle edge cases gracefully.
- Environment Variable Support:
- Allow setting and retrieving environment variables (
export
,$VAR
, etc.).
- Allow setting and retrieving environment variables (
- Advanced Redirection:
- Support
>>
for appending output and<
for input redirection.
- Support
- Job Control:
- Implement proper job control for background processes (e.g.,
fg
,bg
,jobs
).
- Implement proper job control for background processes (e.g.,
- Unit Testing:
- Add test cases to ensure the stability of key features.
-
[Linux Shell Programming Tutorial](https://www.tutorialspoint.com/unix_commands/index.htm
-
[Let's Build a Linux Shell [Part I] by HackerNoon] (https://hackernoon.com/lets-build-a-linux-shell-part-i-bz3n3vg1?)
-
[Write a Shell in C by Stephen Brennan] (https://brennan.io/2015/01/16/write-a-shell-in-c/?)
-
[Making your own Linux Shell in C by GeeksforGeeks] (https://www.geeksforgeeks.org/making-linux-shell-c/?)