Skip to content

RoboShell is a simple, custom-built shell implemented in C++ that mimics basic shell functionality.

Notifications You must be signed in to change notification settings

charan-003/RoboShell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

RoboShell

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.


Features

  • 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 or Ctrl+Z.
  • Command Logging: Logs all commands entered during the session to roboshell_commands.txt.

System Calls Used

  • 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.

Known Issues and Limitations

  1. Path Resolution:
    • Commands must exist in the $PATH for execution. Absolute paths are supported, but missing commands result in a "command not found" error.
  2. Error Handling:
    • Errors are printed to the console but not handled uniformly across all features.
  3. Input Validation:
    • Limited validation for user inputs; incorrect inputs may result in crashes or undefined behavior.
  4. Signal Handling:
    • Signal handling (Ctrl+C/Ctrl+Z) is rudimentary and may not terminate all running background processes properly.
  5. Chaining Commands:
    • Complex command chains with multiple redirections or pipes may behave unexpectedly.
  6. Output Formatting:
    • The shell output formatting could be improved to better mimic standard shells.

Potential Improvements

  • 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.).
  • Advanced Redirection:
    • Support >> for appending output and < for input redirection.
  • Job Control:
    • Implement proper job control for background processes (e.g., fg, bg, jobs).
  • Unit Testing:
    • Add test cases to ensure the stability of key features.

Tutorials I referred to

About

RoboShell is a simple, custom-built shell implemented in C++ that mimics basic shell functionality.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published