diff --git a/src/fsh.nim b/src/fsh.nim index e1c22fe..624ed69 100644 --- a/src/fsh.nim +++ b/src/fsh.nim @@ -274,9 +274,14 @@ proc execute(cmd: string): int = stdout.write(runBuiltin(progname, args)) result = 0 continue - let ps = startProcess(progname, args=args, options={poUsePath, poParentStreams}) - result = ps.waitForExit - ps.close + try: + let ps = startProcess(progname, args=args, options={poUsePath, poParentStreams}) + result = ps.waitForExit + ps.close + except OSError as e: + var e = newException(ShellCommandError, progname & ": command not found") + e.command = progname + raise e strm.close # eval evaluates the given string @@ -291,9 +296,14 @@ proc eval(cmd: string): string = if progname in builtins: result = runBuiltin(progname, args) continue - let ps = startProcess(progname, args=args, options={poUsePath}) - result=ps.outputStream.readAll - ps.close + try: + let ps = startProcess(progname, args=args, options={poUsePath}) + result=ps.outputStream.readAll + ps.close + except OSError as e: + var e = newException(ShellCommandError, progname & ": Command not found") + e.command=progname + raise e strm.close when isMainModule: