Crazy Random Awesome SHell
CRASH is a C++ based shell that provides an interface to execute commands. Commands can be executed from either a user Interactive Mode or a script file in Batch Mode.
- make
- g++
- Clone this repo
- Open the workspace in a terminal
- Use make commands to build
Make Targets:
| make target | description |
|---|---|
| main | Builds the main executable |
| test | Builds the test executable |
| run | Runs the main executable |
| run-test | Runs the test executable |
| clean | Clean build files from the project |
The program can be used in two major ways:
Type external or internal commands directly into CRASH.
# Internal Command
CRASH $ history -l 5
# External Command
CRASH $ lsblkTo run a script in batch mode, there are 3 possible options.
- Give the script a path to CRASH by including
#!PATHTOCRASH- For example, use
#!./bin/mainif inside CRASH's directory, or if inside CRASH's test directory use#!../bin/main.
- For example, use
- Make the script executable by using
chmod +x SCRIPTNAME - Run the script
./SCRIPTNAMEorSCRIPTNAME
- Create a script and run
./bin/main < [script location]
- Create a script and run
./bin/main [script location]
| Character | Usage |
|---|---|
| \ | Continuation |
| # | Comment |
| ; | Split line |
| > | Store |
| >> | Append |
| < | Redirect |
| 2> | Store Error |
| 2>> | Append Error |
\Use backslack to continue a line#Use hashtags to add comments;Use semicolons to seperate lines to run multiple commands at once.- To run both the external
lsblkandlscpucommands. CRASH $ lsblk ; lscpu
- To run both the external
>Use a single greater than character to store the output from a command into a file.- To store the output of
lscputo a file calledoutput.txt CRASH $ lscpu > output.txt
- To store the output of
>>Use two greater than character to append the output from a command to a file.- To append the output of
lsblkto a file calledoutput.txtthat already has existing content. CRASH $ lsblk >> output.txt
- To append the output of
|Use a vertical bar to pipe the output of one program to another.- To pipe the output of
lscputosortto have the output in alphabetical order. CRASH $ lscpu | sort
- To pipe the output of
<Use a less than character to redirect the input of program to a file.- To display the contents of a file called
test5.txt CRASH $ cat < test5.txt
- To display the contents of a file called
Wild cards can be used to find matching files in the current working directory.
-
Question marks (
?) can be used to match any single character in a file name.- Example:
tes?.txtcan be matched totest.txt
- Example:
-
Asterisks (
*) can be used to match any number of characters in a file name.- Example:
t*.txtcan be matched totest.txt
- Example:
-
Square brackets (
[...]) can be used to match the characters inside the bracket.- Example:
test[0-9].txtcan be matched totest5.txt
- Example:
Wildcards can be also be combined with meta characters for advanced functionality.
- To store the names of all files in the current directory to
output.txt CRASH $ echo * > output.txt