Skip to content
Emerging-PatternsPublic

About

snap: program runner for Bend 2

Resources

Stars

0 stars

Watchers

0 watching

Forks

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 LAWS.bend: one file under laws/ each, proved by the file of the same name under proofs/ and checked by bend PROOF.bend (the first line must be ALL PROOFS CHECK). What snap trusts rather than proves, most of all the C and JS effects that start programs, is said on the code that assumes it, in src/effect.bend and main.bend. 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.38.

import snap@1.3.0.0/main.bend as Snap

snap@1.3.0.0 is snap v1.3.0 and resolves to 0xead4c7939c9eaca8d47da53b4496b731; to pin by content, import 0xead4c7939c9eaca8d47da53b4496b731/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.3.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