[v3 PATCH 1/17] exec: Return 126 on most errors in shellexec

2018-05-18 Thread Herbert Xu
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 
---

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

diff --git a/src/exec.c b/src/exec.c
index e9e29b7..d7ced35 100644
--- a/src/exec.c
+++ b/src/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",
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[v2 PATCH 1/12] exec: Return 126 on most errors in shellexec

2018-05-14 Thread Herbert Xu
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 
---

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

diff --git a/src/exec.c b/src/exec.c
index e9e29b7..d7ced35 100644
--- a/src/exec.c
+++ b/src/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",
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


exec: Return 126 on most errors in shellexec

2018-05-03 Thread Herbert Xu
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 

diff --git a/src/exec.c b/src/exec.c
index e9e29b7..d7ced35 100644
--- a/src/exec.c
+++ b/src/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",
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html