Skip to content

About

A custom implementation of the Thompson Shell (sh) built in C for Ubuntu 20.04 LTS

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Holberton School logo

Simple Shell Project

Project Content

Details Overview
Features
Tech stack
Technical Specifications
File Structure
Usage
Author

Overview

This project is the collaboration between Leyla Khaspoladova and David Abdurahmanov. The Simple Shell is a custom implementation of the Thompson Shell (sh). This command-line interpreter provides a user interface for the Unix operating system. The program reads commands from either the standard input or a file and executes them. This project was developed to explore the depths of system calls, process management (fork, exec, wait), and memory management.

Features

  • Dual Execution Modes: Fully functional in both interactive (terminal) and non-interactive (piped) modes.
  • Process Management: Utilises the fork, execve, and wait system calls to manage command execution lifecycles.
  • Path Resolution: Dynamically handles command execution by searching the PATH environment variable.
  • Built-in Commands: Support for internal shell commands, including exit and env.
  • Input Handling: Robust command-line tokenization and handling of the End-of-File (EOF) condition.

Tech stack

C badge Git badge GitHub badge VIM badge

Technical Specifications

Compilation

The shell is compiled using the following flags to ensure code quality and standard compliance:

gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh

Standards and Constraints

  • Style: All code adheres to the Betty Style guide for C.
  • Memory Management: Zero tolerance for memory leaks; verified through systematic testing via valgrind.
  • Modular Design: A strict limit of five functions per source file to ensure maintainability.
  • System Interface: Optimised use of system calls to interact directly with the kernel.

File Structure

FILE FUNCTIONALITY
main.c Core logic and the primary execution loop.
main.h Global header containing prototypes and include guards.
exec.c Logic for command execution and process synchronisation.
args.c String parsing, tokenisation, and PATH handling.
env.c Functions for environment variable access and manipulation.
commands.c Implementation of internal shell built-ins.
man_1_simple_shell Comprehensive manual page for the interpreter.
AUTHORS Credit for project contributors.

Usage

Interactive Mode

$ ./hsh
($) /bin/ls
main.c  main.h  exec.c  hsh
($) exit

Non-Interactive Mode

$ echo "/bin/ls" | ./hsh
main.c  main.h  exec.c  hsh

Author

Leyla Khaspoladova GitHub: @leyla009

About

A custom implementation of the Thompson Shell (sh) built in C for Ubuntu 20.04 LTS

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages