commit 61355c7ccce17bef3cd2a93ed029ffb3e83831fe
parent 766d4b0659755b49ff7aa9fbcfef82931c8432cf
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 12 Sep 2023 08:17:33 +0200
cmd/hare: Print error with command on exec::nocmd
Diffstat:
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/cmd/hare/build.ha b/cmd/hare/build.ha
@@ -176,7 +176,14 @@ fn build(name: str, cmd: *getopt::command) (void | error) = {
fn run(name: str, path: str, args: []str) error = {
const args: []str = if (len(args) != 0) args[1..] else [];
- let cmd = exec::cmd(path, args...)?;
+ let cmd = match(exec::cmd(path, args...)) {
+ case exec::nocmd =>
+ fmt::fatalf("Error: Command not found: {}", path);
+ case let e: exec::error =>
+ return e;
+ case let c: exec::command =>
+ yield c;
+ };
exec::setname(&cmd, name);
exec::exec(&cmd);
};
diff --git a/cmd/hare/build/queue.ha b/cmd/hare/build/queue.ha
@@ -159,7 +159,14 @@ fn run_task(ctx: *context, jobs: *[]job, t: *task) (bool | error) = {
fmt::errorln()?;
};
- let cmd = exec::cmd(ctx.cmds[t.kind], args...)?;
+ let cmd = match(exec::cmd(ctx.cmds[t.kind], args...)) {
+ case exec::nocmd =>
+ fmt::fatalf("Error: Command not found: {}", ctx.cmds[t.kind]);
+ case let e: exec::error =>
+ return e;
+ case let c: exec::command =>
+ yield c;
+ };
path::set(&buf, out)?;
let output = os::create(path::push_ext(&buf, "log")?, 0o644)?;
defer io::close(output)!;