@@ 74,7 74,9 @@ fn _cleanup(s: signal::sig, i: *signal::siginfo, u: *opaque) void = {
};
// Waits for mouse click input, then runs the provided command.
-fn wait_then_run_command(in: io::handle, cmdargs: []str, cmdstr: str) void = {
+fn wait_then_run_command(
+ in: io::handle, cmdargs: []str, cmdstr: str,
+) (void | exec::error) = {
for (let sm: *states::state = &states::start; sm != &states::end) {
// We have to keep an eye on loop because it could be modified
// by the termination signals. We can't have this check in
@@ 122,8 124,8 @@ fn wait_then_run_command(in: io::handle, cmdargs: []str, cmdstr: str) void = {
// Prints the command in bold.
fmt::printfln("{}>> {}{}", "\x1B[1m", cmdstr, "\x1B[0m")!;
- let process = exec::start(&cmd)!;
- exec::wait(&process)!;
+ let process = exec::start(&cmd)?;
+ exec::wait(&process)?;
// Aaand we're back. Our terminal now.
prepare();
@@ 179,9 181,13 @@ export fn main() void = {
prepare();
+ defer cleanup();
+
for (loop) {
- wait_then_run_command(tty, cli.args, cmdstr);
+ match (wait_then_run_command(tty, cli.args, cmdstr)) {
+ case void => void;
+ case let e: exec::error =>
+ fmt::fatal("Process error:", exec::strerror(e));
+ };
};
-
- cleanup();
};