commit 93a427d2a8ae7630a7582933a8236be4bbdd7b8d
parent 512a72e918c38f2d47279b70c9f458a9b8c9b809
Author: Alexey Yerin <yyp@disroot.org>
Date: Thu, 9 Nov 2023 00:32:23 +0300
cmd/hare: Improve 'Command not found' error message in get_version
Signed-off-by: Alexey Yerin <yyp@disroot.org>
Diffstat:
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/cmd/hare/build/util.ha b/cmd/hare/build/util.ha
@@ -19,7 +19,14 @@ use strings;
let buf = path::buffer { ... };
export fn get_version(harec: str) ([]u8 | error) = {
- let cmd = exec::cmd(harec, "-v")?;
+ let cmd = match (exec::cmd(harec, "-v")) {
+ case let c: exec::command =>
+ yield c;
+ case exec::nocmd =>
+ fmt::fatalf("Error: Command not found: {}", harec);
+ case let e: exec::error =>
+ return e;
+ };
let pipe = exec::pipe();
exec::addfile(&cmd, os::stdout_file, pipe.1);
let proc = exec::start(&cmd)?;