A small Unix shell written in C for CSE321 Term Project 1.
This is Group 5's submission for CSE321 Term Project 1. The assignment asks for a working Unix shell in C. The shell runs normal commands, supports redirection and pipes, keeps a command history, and lets Ctrl+C stop the running command without closing the shell.
The full assignment brief is in docs/term-project-1.pdf.
- Runs external commands with
forkandexec. - Built-in
cd,exit, andhistorycommands. - Input and output redirection with
<,>, and>>. - Pipelines with any number of commands, using
|. - Multiple commands with
;and conditional chaining with&&. - Command history with the up and down arrow keys.
- Ctrl+C stops the current child process and returns to the prompt.
You need a C compiler, GNU Make, and a Unix-like system. The shell was built and tested on Linux.
git clone https://github.com/sjnakib/Unix-Shell-Lite.git
cd Unix-Shell-Lite
make
./unix-shell-liteThe build creates the unix-shell-lite executable in the project root. To remove the build files:
make cleanTo run the tests, you also need Python 3:
make testStart the shell and try a few commands:
sh> echo hello > note.txt
sh> cat note.txt
hello
sh> cat note.txt | wc -l
1
sh> true && echo done
done
The history command prints the commands from the current session:
sh> history
1: echo hello > note.txt
2: cat note.txt
3: cat note.txt | wc -l
4: true && echo done
5: history
.
├── .github/
│ └── workflows/
│ └── ci.yml # build and test workflow
├── docs/
│ └── term-project-1.pdf # assignment brief
├── include/
│ └── shell.h # shared constants and prototypes
├── src/
│ ├── executor.c # built-ins and redirection
│ ├── history.c # history storage and output
│ ├── line_editor.c # raw-mode input and arrow keys
│ ├── main.c # prompt loop and command dispatch
│ ├── parser.c # tokenizing, ; and && handling
│ ├── pipeline.c # pipe creation and waiting
│ └── signals.c # Ctrl+C handling
├── tests/
│ ├── shell_session.py # pty helper for interactive tests
│ └── test_shell.py # integration tests
├── CHANGELOG.md
├── LICENSE
├── Makefile
└── README.md
CSE321 Section 17, Group 5:
- Shafaat Jamil Nakib
- Pranjal Basak
- Md. Ashraful Islam Sami
This project is licensed under the MIT License. See LICENSE for the full text.