Skip to content

autom8nerd/mini-shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Mini Shell (C, Linux)

A minimal Unix-like shell implemented in C, built to understand how command execution, process management, and system calls work at the operating system level. This project focuses on low-level interaction with Linux rather than feature completeness.

Overview

This shell provides a basic REPL (Read–Eval–Print Loop) that reads user input, parses commands, resolves executable paths, and executes programs using Linux system calls. It implements core shell functionality from first principles to explore how user-space programs interact with the operating system.

The goal of this project is learning systems programming concepts, not replicating a full-featured shell like bash or zsh.


Features Implemented

  • Interactive command prompt (REPL)
  • Command parsing and argument handling
  • Execution of external programs
  • Built-in commands:
    • exit – terminate the shell
    • echo – print arguments to stdout
    • type – identify built-in vs external commands
  • PATH resolution and executable lookup
  • Invalid command handling
  • Signal handling (basic support)
  • Direct use of Linux system calls (fork, exec, wait, file descriptors)

System Concepts Covered

This project provides hands-on experience with:

  • Process creation and execution (fork, exec)
  • Parent–child process relationships
  • Command dispatch and program loading
  • File descriptors and standard I/O
  • Environment variables and PATH resolution
  • Basic signal handling
  • REPL design pattern
  • User–kernel interaction through syscalls

Architecture

High-level flow:

  1. Print shell prompt
  2. Read user input
  3. Parse input into command + arguments
  4. Handle built-in commands
  5. Resolve executable path
  6. Create child process (fork)
  7. Execute program (exec)
  8. Wait for completion (wait)
  9. Loop back to prompt

Build Instructions

gcc -o minishell main.c

Design Philosophy

This project prioritizes:

  • understanding OS-level behavior
  • correctness of system call usage
  • clarity of control flow
  • learning Linux internals

Limitations (Intentional)

This is not a full POSIX-compliant shell. The following features are intentionally not implemented yet:

  • pipelines
  • redirection
  • job control
  • command history
  • autocompletion
  • advanced quoting
  • background processes
  • scripting

These are planned extensions for future versions.


Motivation

The purpose of this project is to learn how real shells work internally by building one from scratch in C. It is part of a broader effort to understand operating systems, low-level programming, and Linux internals through practical implementation.


Future Work

Planned improvements include:

  • I/O redirection (>, <, >>)
  • pipelines (|)
  • command history
  • signal handling improvements
  • job control
  • improved parsing and tokenization
  • structured command execution pipeline

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages