brenns10/lsh logo

brenns10/lsh

Free

Simple shell implementation. Tutorial here ->

FreeFree tier
Type
Open Source

About brenns10/lsh

LSH is a simple implementation of a shell in C, designed as an educational tool to demonstrate the fundamental workings of a Unix shell. It follows the core loop of reading input, parsing commands, forking a child process, executing the command, and waiting for completion. The project is accompanied by a tutorial on the author's website, making it an ideal starting point for learning shell internals. While not feature-complete, it provides clear, minimal code that illustrates key concepts like process management and command execution. The shell supports basic built-in commands (cd, help, exit) and requires commands to be on a single line with whitespace-separated arguments. It is released into the public domain under the Unlicense, allowing unrestricted use and modification.

Key Features

Demonstrates core shell loop: read, parse, fork, exec, wait
Includes three built-in commands: cd, help, exit
Accompanied by a step-by-step tutorial on writing a shell
Minimal, clean C codebase (single source file)
Public domain license for unrestricted use and modification
Optional use of standard getline via compile flag

Pros & Cons

Pros
  • Excellent educational value with a clear tutorial
  • Simple and easy-to-read code, ideal for beginners
  • Public domain license removes any legal restrictions
  • Lightweight and compiles with gcc without external dependencies
  • Demonstrates fundamental Unix system calls (fork, exec, wait)
Cons
  • Limited functionality: no piping, redirection, command quoting, or escaping
  • Commands must be on a single line with whitespace-separated arguments
  • Only three built-in commands (cd, help, exit); no job control or scripting
  • Not intended for production or everyday use
  • Author not accepting feature contributions, only bug fixes

Best For

Learning operating system concepts like process creation and executionEducational projects for understanding how shells work internallyStarting point for building custom lightweight shellsTeaching Unix programming and system calls in a classroom setting

FAQ

How do I compile and run LSH?
Use gcc -o lsh src/main.c to compile, then ./lsh to run. Optionally use gcc -DLSH_USE_STD_GETLINE -o lsh src/main.c to enable the standard getline implementation.
Can I contribute new features to LSH?
The author is not looking to extend LSH with additional features at this time. Only bug fixes are accepted. However, you are encouraged to fork the code and explore new features on your own.
What license is LSH released under?
LSH is in the public domain under the Unlicense. You can use, modify, and distribute it without restriction.
What does LSH demonstrate?
LSH demonstrates the basics of how a shell works: reading input, parsing commands, forking a child process, executing the command, and waiting for it to finish.