aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-09-14 06:01:51 +0000
committer_ov4 <ov4@ov4.org>2026-09-14 06:01:51 +0000
commit38c1b9ef51ef327a019cf6a8c99c363882e7ee74 (patch)
treec24c3b75db5e590e80eede6e6e0deefa8400729e /src
parent66fd6696283507643c4b08d3bd91480ae2971e73 (diff)
add error output
Diffstat (limited to 'src')
-rw-r--r--src/eval.cc30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/eval.cc b/src/eval.cc
index 3b3a3ba..f25f6cd 100644
--- a/src/eval.cc
+++ b/src/eval.cc
@@ -67,12 +67,36 @@ void eval(char *cmdline)
// program inside execve may use SIGTTIN/SIGTTOU so just restore in child
sigprocmask(SIG_UNBLOCK, &block_io, nullptr);
-
execve(cmd_c, argv, environ);
wrap_eliminator(cmdline);
- cout << cmdline << ": Command not found" << endl;
- exit(-1); // if no command is found
+ cout << cmdline << flush;
+ switch (errno)
+ {
+ case ENOTDIR:
+ println(": A component of the path prefix is not a directory.");
+ exit(errno);
+ break;
+
+ case ENAMETOOLONG:
+ println(": A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters.");
+ exit(errno);
+ break;
+
+ case ENOENT:
+ println(": The new process file does not exist.");
+ exit(errno);
+ break;
+
+ case EACCES:
+ println(": The new process file mode denies execute permission.");
+ exit(errno);
+ break;
+
+ default:
+ println(": Error, code: {}", errno);
+ exit(errno);
+ }
}
// parent