Skip to content

About

A small Unix shell written in C for CSE321 Term Project 1, with pipes, redirection, command history, and Ctrl+C handling.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

31 Commits

Folders and files

Repository files navigation

Unix Shell Lite 🐚

A small Unix shell written in C for CSE321 Term Project 1.

Stars Forks Last commit Top language License Release CI

About

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.

Features

  • Runs external commands with fork and exec.
  • Built-in cd, exit, and history commands.
  • 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.

Tech Stack

C GNU Make Linux Git

Getting Started

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-lite

The build creates the unix-shell-lite executable in the project root. To remove the build files:

make clean

To run the tests, you also need Python 3:

make test

Usage

Start 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

Project Structure

.
├── .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

Authors

CSE321 Section 17, Group 5:

  • Shafaat Jamil Nakib
  • Pranjal Basak
  • Md. Ashraful Islam Sami

License

This project is licensed under the MIT License. See LICENSE for the full text.

About

A small Unix shell written in C for CSE321 Term Project 1, with pipes, redirection, command history, and Ctrl+C handling.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages