https://github.com/big-shahmir/mini-bash
A minimal shell implementation designed to support basic shell functionality, including executing built-in commands, handling user input, and managing processes. This project is an educational exercise to understand how shells work at the system level.
https://github.com/big-shahmir/mini-bash
bash c script shell
Last synced: 2 months ago
JSON representation
A minimal shell implementation designed to support basic shell functionality, including executing built-in commands, handling user input, and managing processes. This project is an educational exercise to understand how shells work at the system level.
- Host: GitHub
- URL: https://github.com/big-shahmir/mini-bash
- Owner: Big-ShahMir
- License: mit
- Created: 2024-12-28T06:25:38.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-28T07:45:44.000Z (over 1 year ago)
- Last Synced: 2025-03-17T22:07:50.385Z (over 1 year ago)
- Topics: bash, c, script, shell
- Language: C
- Homepage:
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tiny Shell (tsh)
## Overview
Tiny Shell (tsh) is a minimal shell implementation designed to support basic shell functionality, including executing built-in commands, handling user input, and managing processes. This project is an educational exercise to understand how shells work at the system level.
---
## Features
- **Prompt Display**: Displays a custom prompt (`tsh> `) to take user commands.
- **Built-in Commands**:
- `cd `: Change the current working directory.
- `exit`: Exit the shell.
- `help`: Display information about the shell.
- **Process Execution**: Supports running external programs.
- **Background Processes**: Supports running processes in the background using `&`.
- **Signal Handling**: Gracefully handles `SIGINT` (Ctrl+C) and other signals.
- **Error Handling**: Handles invalid commands and arguments gracefully.
---
## File Information
### Files used to test your shell:
- sdriver.pl : The trace-driven shell driver
- trace*.txt : The 17 trace files that control the shell driver
- tshref.out : Example output of the reference shell on all 17 traces
### Little C programs that are called by the trace files:
- myspin.c : Takes argument and spins for seconds
- mysplit.c : Forks a child that spins for seconds
- mystop.c : Spins for seconds and sends SIGTSTP to itself
- myint.c : Spins for seconds and sends SIGINT to itself
## Build and Usage Instructions
### Prerequisites
- GCC or any C compiler
- Linux or macOS environment (not tested on Windows)
- Make utility
### Build the Shell
```bash
make
```
### Run the Shell
```bash
./tsh
```
## How to Use
1. Launch the Shell: Run `./tsh` to start the Tiny Shell. The shell prompt will appear as `tsh>`.
2. Execute Commands:
- To run a command in the foreground:
```bash
tsh> ls -l
```
- To run a command in the background:
```bash
tsh> sleep 10 &
```
3. Built-in Commands:
- Quit the Shell:
```bash
tsh> exit
```
## Contributing
Contributions are welcome! Feel free to submit issues or pull requests to improve this program.
## License
This project is licensed under the MIT License. See `LICENSE` file for details.