src/share/exec.bend

ezx@1.9.0.0 · 25 lines · 0 definitions

1# share/exec: a program run with this project's BEND_LIB in front of it, and
2# the directories bend writes into made before it starts. share/env decides
3# what the line and the directories are; this runs them, through snap's
4# foreign effect, and lives apart because bend 2.0.32 fails a proof whose
5# imports reach foreign code, so a law may import share/env but never this.
6import Base
7import snap@1.3.0.0/main.bend as R
8import ezx@1.9.0.0/src/share/env.bend as Env
9
10# a program run with this project's BEND_LIB set for it
11def exec(args: List<&2, String>) -> IO(String):
12  do IO<String>:
13    at : String <- Env.lib()
14    R.exec(Env.line(at, args))
15
16# those directories made. Base has no mkdir, so this is coreutils, and no
17# directory means no run at all.
18def make(ds: List<&2, String>) -> IO(Unit):
19  match ds:
20    case []:
21      IO.pure(Unit, Unit{})
22    case h <> t:
23      do IO<Unit>:
24        _mk : String <- R.exec(List.append(&2, String, ["mkdir", "-p"], h <> t))
25        return Unit{}