Skip to content

Repository files navigation

snap

Program runner for Bend 2. Pass argv as a list of strings — no shell — and get back exit status, stdout, and stderr. start returns a pid without waiting; par runs several jobs together. Helpers join argv and read answers.

Every argument reaches the program whole, newlines and all. An argv that could not arrive whole, one with no program name or with NUL inside an argument, is refused: run answers status 127 and start answers 0, and nothing is run. In par, a refused job answers 127 in its own place.

What snap guarantees is listed in SPEC.md: each requirement is either proved by a quantified law in LAWS.bend (proofs in PROOF.bend, shared lemmas in check/) or named as a trusted assumption about the C and JS effects that start programs. The reasoning is in docs/rfc/snap-spec.md.

Install

With Bend alone there is nothing to install: import snap by its hub name and version, and bend fetches it from the hub into ~/.bend/lib on the first run; no install step. snap is built and checked on Bend 2.0.34.

import snap@1.1.0.0/main.bend as Snap

snap@1.1.0.0 is snap v1.1.0 and resolves to 0xabe575924687afad4cee1a2c1194d639; to pin by content, import 0xabe575924687afad4cee1a2c1194d639/main.bend instead.

Or with ez, which records the package in ez.toml (ez init makes one):

ez add Emerging-Patterns/snap

Usage

run answers with the exit status on its own first line, then stdout and stderr together. Snap.code reads the status; Snap.text reads the body.

import snap@1.1.0.0/main.bend as Snap

def main() -> IO(Unit):
  do IO<Unit>:
    +out : String <- Snap.run(["echo", "hello"])
    IO.print(Snap.code(out))
    IO.print(Snap.text(out))
git clone https://github.com/Emerging-Patterns/snap
cd snap
mkdir -p bin
bend examples/demo/main.bend -o bin/demo.bin
bin/demo.bin

About

snap: program runner for Bend 2

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages