Skip to content

The Biggest Shell Programs in the World

andychu edited this page May 6, 2022 · 30 revisions
Clone this wiki locally

Help me fill out this page! It's freely editable.

What programs should be listed? I'm using "biggest" in the sense of substantial, not necessarily the raw number of lines.

  • Hand-written shell scripts. There are many big autoconf-generated scripts, like the 70K-line coreutils script, but I don't consider them substantial in this sense.
  • Shell programs that use data structures and algorithms.
    • As a counterexample, bash-completion is pretty sophisticated, but it's also repetitive because it has a relatively simple function for every command on a Unix machine.
  • Shell programs that are over 5K lines (though there may be exceptions). The biggest shell programs that aren't repetitive tend to be in the 10K+ line range. I haven't seen any programs over 100K lines.

The List

  • akinomyoga/ -- 61K LoC (46K SLoC) in total. Bash Line Editor---fish-like interactive line editor in pure bash! The main file out/ has 30K lines of code (23K SLoC), but there are 60K+ lines of code in the repo in total. There are many comments (in Japanese).
    • How Interactive Shells Work has a nice overview of how works. It's very sophisticated, using bind -x to read raw bytes from the terminal, decoding those itself in mulitiple explicit state machines, maintaining a drawing buffer, updating the buffer, etc. It has timing and "fibers", etc.
    • This comment on issue 663 has details on the shell parser! I think this is one of the most sophisticated uses of data structures in shell I've seen.
    • We are trying to run under Oil. It mostly parses.
    • First commit in 2015 with 8K LoC / 6 SLoC. The actual development has started in 2013.
  • bashdb, the bash debugger. ~14K lines of bash. Interesting history: Implementing Debuggers
  • drwetter/ -- 21K lines of bash in a single file! Appears to be hand-written. History: Back in 2006 it started with a few openssl commands.... (Hit issue #606 parsing it.)
  • Simplenetes: Kubernetes in 17K lines of Shell. Amazing! But seems dormant. Hacker News Thread.
  • rkhunter (official site) -- 21K lines of Bourne shell written from 2003-2018!
  • romkatv/powerlevel10k -- 12K lines of zsh scripts in the directory internal/. There are other 8K lines of configs and helper scripts. First commit in 2014.
  • dylanaraps/neofetch -- 10K lines of bash 3.2. Displays system information. May also do something interesting with images (?)
    • first commit 2015
  • xwmx/nb -- 24K LoC (19K SLoC) of bash in nb itself. An additional 86K LoC (55K SLoC) if we count bats tests as bash.
    • First commit in 2014, but active commit history starts in early 2016.
  • -- 7K lines of shell script. Issues and renews certificates.
  • inxi 2.3.56 [obsolete] -- 16K lines of bash. A fork of infobash in 2008 (889 lines then). infobash has started in 2005. From v2.9, inxi is replaced by the Perl implementation.
  • bashforth -- At ~3800 lines this isn't huge, but it apparently implements a real programming language. It has a lot of whitespace and comments.
  • vegardit/bash-funk -- 27K LoC (24K SLoC) in total. A Bash library. The first commit in May, 2017 (with 10K LoC / 8K SLoC).

Shell-Like Languages / DSLs

  • modernish is a portable shell dialect written in shell
  • bats is a DSL for writing tests. Generates bash code.
  • bashible is an Ansible-like DSL in bash. comments
  • clash is an object oriented framework compatible with any modern POSIX shell.
  • bash Infinity is a standard library and a boilerplate framework for bash.

Smaller Programs

  • Alpine, Aboriginal, Debian scripts -- see blog post
  • Completion scripts are big, but often repetitive.
    • _git Zsh completion -- 8.3k lines of code
    • git-completion.bash
    • Docker completion
  • dyne/Tomb is a ~3500 line zsh script.