[klibc] [klibc:update-dash] dash: exec: Return 126 on most errors in shellexec

klibc-bot for Herbert Xu herbert at gondor.apana.org.au
Sat Mar 28 14:49:14 PDT 2020


Commit-ID:  2cb3d00d728a1ebfe87818161b7a13dc2b6598ed
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=2cb3d00d728a1ebfe87818161b7a13dc2b6598ed
Author:     Herbert Xu <herbert at gondor.apana.org.au>
AuthorDate: Sat, 19 May 2018 02:39:37 +0800
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Sat, 28 Mar 2020 21:42:55 +0000

[klibc] dash: exec: Return 126 on most errors in shellexec

[ dash commit a332ebdaa13d3eaf70082e1be214c42645bc186a ]

Currently when shellexec fails on most errors the shell will exit
with exit status 2.  This patch changes it to 126 in order to avoid
ambiguities with the exit status from a successful exec.

The errors that result in 127 has also been expanded to include
ENOTDIR, ENAMETOOLONG and ELOOP.

Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>

---
 usr/dash/exec.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/usr/dash/exec.c b/usr/dash/exec.c
index e9e29b7e..d7ced357 100644
--- a/usr/dash/exec.c
+++ b/usr/dash/exec.c
@@ -130,15 +130,15 @@ shellexec(char **argv, const char *path, int idx)
 
 	/* Map to POSIX errors */
 	switch (e) {
-	case EACCES:
+	default:
 		exerrno = 126;
 		break;
+	case ELOOP:
+	case ENAMETOOLONG:
 	case ENOENT:
+	case ENOTDIR:
 		exerrno = 127;
 		break;
-	default:
-		exerrno = 2;
-		break;
 	}
 	exitstatus = exerrno;
 	TRACE(("shellexec failed for %s, errno %d, suppressint %d\n",


More information about the klibc mailing list