Skip to content
ManyaJain111Public

About

C Shell implementation, replicating the core behavior of standard shells like Bash or Zsh, while remaining intentionally minimal

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

C Shell Project: msh Shell

Name: Manya Jain


Introduction

msh is a custom, interactive command-line interpreter (shell) written in C. It aims to replicate the core behavior of standard shells like Bash or Zsh, while remaining intentionally minimal. Despite its simplicity, it supports built-in commands, external program execution, input/output redirection, background processing, and persistent command history.

Project Structure

The project is organized to ensure modularity and clean compilation.

   ├── makefile              # Build automation configuration
   ├── shell.h               # Main header file (structs, global vars, prototypes)
   ├── msh               # Final executable (generated after make)
   ├── README.md             # Documentation
   ├── src/                  # Source code directory
   │   ├── main.c
   │   ├── prompt.c
   │   ├── builtins.c
   │   ├── history.c
   │   ├── process.c
   │   ├── signal_handlers.c
   │   └── utils.c
   └── build/                # Object files (.o) directory (generated during build)
       ├── main.o
       ...

Compilation & Execution 🛠️💖

This project uses a Makefile to do the heavy lifting, so you don’t have to. Just a few simple commands :

1. Compile the Shell

Build the project and create the msh executable:

make

Or if you like being extra :

make all

2. Run the Shell

Once compiled, execute the shell:

./msh

3. Clean Build Files

To remove the msh executable and the build/ directory (and object files):

make clean

Features Implemented

  1. Shell Prompt
    Displays <user@system:path> with colored formatting and support for ~ as a relative home directory path.

  2. Built-in Commands

    • pwd: Display the current working directory.
    • cd: Change the current directory (supports .., ~, and -).
    • help: Show the help menu.
    • echo: Print arguments to standard output.
    • exit: Exit the shell cleanly.
    • history: Display the last 20 executed commands.
  3. Input/Output Redirection

    • Output redirection: command > output.txt
    • Input redirection: command < input.txt
  4. External Commands
    Executes standard system programs such as ls, vim, and grep.

  5. Signal Handling

    • Ctrl+D: Exits the shell.
    • Ctrl+C: Terminates the foreground process without exiting the shell.
  6. Background Execution
    Supports background processes using & (e.g., docker-compose build &).

  7. Command History Persistence
    Command history is stored in ~/.msh_history and restored on subsequent sessions.

About

C Shell implementation, replicating the core behavior of standard shells like Bash or Zsh, while remaining intentionally minimal

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages