hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit ee9c889bc08b80d70de0b6adcae499844f7551a5
parent 3f04b38006d9bc0cdd4355ec299ab3782fca92eb
Author: Hugo Osvaldo Barrera <hugo@whynothugo.nl>
Date:   Sun, 19 May 2024 21:53:10 +0200

os::exec: return concrete error when feasible

When using `os::exec::cmd("/path/to/to/command")`, if the supplied path
points to a non-executable file, `os::exec::nocmd` is returned. This is
not correct and confuses consumers.

Return the original, clearer, error from `os::exec::open` instead.

Signed-off-by: Hugo Osvaldo Barrera <hugo@whynothugo.nl>

Diffstat:
Mos/exec/cmd.ha | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/os/exec/cmd.ha b/os/exec/cmd.ha @@ -26,8 +26,8 @@ export fn cmd(name: str, args: str...) (command | error) = { yield match (open(name)) { case let p: platform_cmd => yield p; - case => - return nocmd; + case let err: error=> + return err; }; } else { yield match (lookup_open(name)?) {