Skip to content

joshsj425-hub/myshell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

myshell — Minimal Unix-Style Shell in C

Overview

myshell is a lightweight Unix-style command-line shell implemented in C.
The project is focused on core operating system concepts such as process creation, inter-process communication, file descriptor manipulation, and concurrent execution using low-level system calls.

It demonstrates how a basic shell operates internally at the system level.


Features

  • Execute external programs using fork() and execvp()
  • Input redirection (<)
  • Output redirection (>)
  • Pipe support (|)
  • Background execution (&)
  • Built-in cd command
  • Synchronization using wait()

Implementation Details

The shell is built using standard Unix system calls:

  • fork() — Creates child processes
  • execvp() — Executes external commands
  • pipe() — Enables communication between processes
  • dup2() — Redirects standard input and output
  • wait() — Synchronizes parent and child processes
  • chdir() — Changes the working directory

Commands are divided into arguments using strtok().

Redirection is handled in the child process before executing commands.


Build Instructions

Compile the project using:

  • make Or manually:
  • gcc -Wall -Wextra -std=c11 -g src/myshell.c -o myshell

Run Instructions

Start the shell with: ./myshell

You will see the prompt: myshell>


Example Commands

  • Basic execution —— ls
  • Pipe —— ls | wc
  • Output redirection —— echo hello > output.txt
  • Input redirection -— sort < input.txt
  • Background execution -— sleep 5 &
  • Built-in command -— cd src

Purpose

This project was created to strengthen understanding of Unix process management and systems programming in C.
It is able to demonstrate practical use of operating system primitives to build a functional command shell.

About

A minimal Unix-style shell written in C that supports pipes, redirection, background execution, and built-in commands using low-level system calls.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors