~/bend-docscommunity

main.bend relies on unsafe/foreign

raw source on the hub · import snap@1.1.0.0/main.bend as Main

snap: run programs from Bend 2 with argv as a list of strings, no shell.

run (and exec) run a program and answer its exit status on its own first line, then stdout and stderr together; code, text and ok read that answer. start leaves a program running and answers its pid. par runs several at once. Every argument reaches the program whole; an argv with no program name, or with NUL inside an argument, is refused and nothing runs. cmd and line join argv on newlines. This file is the interface: everything under src/ is internal.

5 imports
import Base
import ./src/effect.bend as Effect
import ./src/argv.bend as Argv
import ./src/answer.bend as Answer
import ./src/par.bend as Par

Definitions

def run source · line 18 · raw

@argv:List<&2, String> -> IO(String)

a program run with its arguments: the exit status on its own first line, then stdout and stderr together. A refused argv answers 127 and runs nothing.

def exec source · line 22 · raw

@argv:List<&2, String> -> IO(String)

a program run with its arguments; the same as run

def start source · line 27 · raw

@argv:List<&2, String> -> IO(String)

a program started with its arguments and left running; the answer is its pid, or 0 when it could not be started or its argv was refused

def par source · line 36 · raw

@js:List<&2, List<&2, String>> -> @+width:String -> @+gb:String -> @+at:String -> @+by:String -> IO(List<&2, String>)

several programs run at once, each answered exactly as run answers one, in the order the jobs were given; a job run would refuse answers 127 in its place. at is a directory the caller owns and this fills: job n writes to at/n. A width of "" leaves the count to the effect, which reads the cores and divides them by gb, the memory cap each job runs under. by is the second every job must be finished by, or "0" for none.

def code source · line 50 · raw

@out:String -> String

the exit status an answer holds: everything before its first newline

def text source · line 55 · raw

@out:String -> String

what the program printed, stdout and stderr together: everything after the answer's first newline

def ok source · line 59 · raw

@+out:String -> Bool

whether an answer's status is 0

def cmd source · line 63 · raw

@argv:List<&2, String> -> String

the arguments joined on newlines, the wire ez's pass effect reads

def line source · line 67 · raw

@argv:List<&2, String> -> String

the arguments joined on newlines; the same as cmd