A compact, minimal Linux shell written in C++
An external command is executable if it is defined in system's PATH
variable. For example, if you want to run ls
and the executable is at /usr/bin/ls
, then PATH
must contain /usr/bin
.
Two built-in commands are supported:
exit
to exit the shellsteve
to list all the suspended jobs
Currently supports up to 2 chaining commands.
Symbol | Explanation |
---|---|
| |
Pipe: Used to pass the output of one command as input to another command. |
|| |
Logical OR: Executes the second command only if the first command fails. |
&& |
Logical AND: Executes the second command only if the first command succeeds. |
If any command exits with an error, an error message is printed to let them know. If there are 2 commands (in the case of pipe, AND, OR), the exact command that causes the problem will be identified.
Two keyboard-triggered signals are supported:
- Ctrl+C (SIGINT) to terminate foreground process group
- Ctrl+Z (SIGTSTP) to suspend foreground process group (currently cannot resume suspended process yet)
Past commands are saved in .nutshell_history
file in the same directory as the shell is spawned. Using arrow key up/down and Enter to run past command:
Reusing an existing project of a group member, this shell has a frontend that was built and setup from scratch!
Source repo: terminix
- GCC 14.1.1
- CMake >= 3.16
If you are running on MacOS then install GCC-14 via brew.
- The recommended editor is Visual Studio Code
- Clone the repository &&
cd
into it
git clone https://github.com/lanphgphm/nutshell.git
cd nutshell
- Add your code to
src/
directory
- It is recommended that you put all imports and method signatures into a
class.h
file. Theclass.cpp
file is only for implementation. - See class template in
src/templates/
(don't add your code under this directory).
- Compile source code & run app On Linux:
mkdir -p build
cd build
cmake .. && cmake --build . && ./appnutshell
On MacOS:
cmake -DCMAKE_C_COMPILER=/usr/local/bin/gcc-14 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-14 .. && cmake --build . && ./appnutshell
Not ready to be shipped to end-user.