blood logo

blood

blood is a POSIX shell built for performance, reliability and ergonomics.

for x in ["hello", "world"] {
    shell("cowsay " + x)
}

Overview

blood outperforms ksh and dash on several benchmarks, and outperforms Elvish and Fish by up to 120x on general purpose tasks. Methodology and results are published at Shell Arena.

The shell and the language are one. Shell commands are values, strings interpolate, and loops hold real data. There are no quoting layers to get tangled with.

Examples

Functions, globbing, string interpolation and arithmetic work together in ordinary scripts:

fn lines(path) {
    return len(read_file(path).strip().split("\n"))
}

total = 0

for file in glob("src/*.sx") {
    n = lines(file)
    total += n
    say "{file}: {n} lines"
}

say "source total: {total} lines"

Captured commands are ordinary strings, so they can be stripped, split and compared directly:

branch = capture("git branch --show-current").strip()
say "working on {branch}"

changes = capture("git status --porcelain").strip()
if changes != "" {
    for change in changes.split("\n") {
        say "  {change}"
    }
}

Parallelism is a keyword. Every iteration of a para for loop runs as a child process, so there are no thread pools and no async/await.

para for file in glob("src/*.sx") {
    say capture("sha256sum {file}").strip()
}

Resources