def exec.finish

ezx@1.11.0.0 · src/tool/run.bend:234

import ezx@1.11.0.0/src/tool/run.bend as Run
import Base
import snap@1.4.0.0/main.bend as R
import ezx@1.11.0.0/src/share/say.bend as Say
import ezx@1.11.0.0/src/share/pass.bend as Pass
import ezx@1.11.0.0/src/tool/plan.bend as TP

234# the program started with its words on ez's own stdin, stdout and stderr,
235# or the link written, and the status the program exited with, 0 when none
236# was started. What the program prints reaches the person as it prints it,
237# and it reads what ez would have read.
238def exec.finish(fin: TP.Finish) -> IO(U32):
239  match fin:
240    case TP.Idle{}:
241      IO.pure(U32, 0)
242    case TP.Launch{bin, args}:
243      Pass.run(List.append(&2, String, [bin], args))
244    case TP.Link{bin, +dir, +name, says}:
245      +at = dir ++ "/" ++ name
246      do IO<U32>:
247        IO.print_err(Say.linking(at))
248        _mk : String <- R.exec(["mkdir", "-p", dir])
249        +ln : String <- R.exec(["ln", "-sfn", bin, at])
250        link.after(R.ok(ln), at, R.text(ln), says)
251        return 0

Uses (17)

Used by (1)