A basic command-line tool (REPL) that supports executing commands, handling executable paths, and redirecting output to files. It demonstrates various functionalities such as interpreting commands, executing system commands, and handling input/output redirection.
- Command Execution: Allows you to execute commands from your system's PATH.
- Echo Command: Outputs input to the console or redirects it to a file.
- Custom Command Handling: Users can define custom commands to be executed.
- File Output Handling: Supports redirection of output (standard output and error output) to files.
- C++17 or higher
- A C++ compiler (e.g.,
g++
orclang++
) - Cmake
- vcpkg
- Clone the repository:
git clone https://github.com/Rachit2912/shellB.git
- Navigate to the project directory:
cd shellB
- Compile the program:
open wsl (windows subsustem for linux) in the shellB folder and run this command :
press 'i' and now edit the vcpkg directory where vcpkg is installed and save by pressing 'esc' => ':wq'
vim shellB.sh
- Run the program:
./shellB.sh
Once the program starts, you will be prompted with a basic REPL interface. You can input commands, such as:
- *** echo ***: Output text to the console.
- *** pwd *** : Prints the current working directory
- *** cd *** : Changing the directory (supports absolute,relative paths, ./ , ../ , ~ & many more linux file standards)
- *** > / 1> *** : Output redirection to a file
- *** 2> *** : Error redirection to a file
- *** >> / 1>> *** : Output addition to a file
- *** 2>> *** : Error addition to a file
- *** exit 0 ***: Exit the program
- *** RJ *** : About section of the shell
- Command Parsing: The program reads user input, parses the command, and executes the corresponding action.
- Command Mapping: Commands like
exit
,echo
,pwd
,cd
&RJ
are mapped to functions usingstd::map
. - Path Lookup: The program can search for executables within directories specified in the system's
PATH
environment variable. - Output Redirection: Supports
>
,1>
,2>
,>>
,1>>
, and2>>
for redirecting output to files.