Skip to content
arwin-swapnaPublic

About

rush (Rapid Unix SHell) is a simple, efficient Unix shell implemented as a command line interpreter (CLI).

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

🐚 rush — Rapid Unix Shell (C)

rush is a lightweight Unix shell written in C that implements core shell functionality including command execution, built-in commands, redirection, and parallel processing.

The goal of this project is to demonstrate process management, system calls, and command parsing in a Unix/Linux environment.


📌 Overview

rush is a command-line interpreter that repeatedly:

  1. Displays a prompt
  2. Reads user input
  3. Parses the command
  4. Executes the command
  5. Waits for completion
  6. Repeats until the user exits

Example prompt:

rush>

✨ Features

  • Command prompt and execution loop
  • Built-in commands: exit, cd, path
  • Executable path resolution
  • Output redirection (>)
  • Parallel command execution (&)
  • Robust error handling
  • Flexible whitespace parsing

🏗️ Project Structure

.
├── makefile
├── rush.c
└── README.md

⚙️ Build Instructions

Requirements

  • Linux environment
  • GCC

Compile

make

This produces the executable:

./rush

▶️ Running the Shell

./rush

You will see:

rush>

Type commands just like a normal Unix shell.


🧠 How It Works

Command Execution

External commands are executed using:

  • fork() — create child process
  • execv() — run the program
  • wait() / waitpid() — wait for completion

The shell searches for executables using directories defined in the path list.

Default path:

/bin

🔧 Built-in Commands

exit

Exits the shell.

rush> exit

Rules:

  • No arguments allowed.

cd <directory>

Changes the current working directory.

rush> cd /tmp

Rules:

  • Must receive exactly one argument.

path [dir1 dir2 ...]

Sets the executable search path.

rush> path /bin /usr/bin

Clear the path:

rush> path

📤 Output Redirection

Redirect command output using >:

rush> ls -la > files.txt

Behavior:

  • Output file is created if it does not exist
  • Existing files are overwritten
  • Errors during file creation are reported

⚡ Parallel Execution

Use & to run commands simultaneously:

rush> sleep 1 & ls & echo done

The shell waits until all commands finish before showing the next prompt.


❗ Error Handling

All errors print a single message to stderr:

An error has occurred

The shell continues running after most errors.


🧪 Example Session

rush> path /bin
rush> ls
rush> cd /tmp
rush> ls > output.txt
rush> sleep 1 & echo hello & ls
rush> exit

About

rush (Rapid Unix SHell) is a simple, efficient Unix shell implemented as a command line interpreter (CLI).

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages