On Wed, Oct 06, 2010 at 08:04:58PM -0500, Jonathan Nieder wrote:
> This reverts commit c0e07c010e5abdea1a7d1357edb1d08adac529cb.
> 
> Yes, it is nicer to pass the exit status through the exitstatus
> global, but look at the consequences:
> 
>  $ sh -c 'exec nonexistent'; echo $?
>  exec: 1: nonexistent: not found
>  2
>  $ sh -c 'exec .'; echo $?
>  exec: 1: .: Permission denied
>  2
> 
> According to POSIX:
> "If command is not found, the exit status shall be 127. If command is
> found, but it is not an executable utility, the exit status shall
> be 126."
> 
> Make it so again.
> 
> Reported-by: Eric Blake <ebl...@redhat.com>
> Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>

Actually the bug is elsewhere.  This patch works for me.

commit 7f684260a2426ac61c06d2e4822429b00437ae24
Author: Herbert Xu <herb...@gondor.apana.org.au>
Date:   Thu Oct 7 10:55:15 2010 +0800

    [BUILTIN] Fix EXEXEC status clobbering
    
    evalcommand always clobbers the exit status in case of an EXEXEC
    which means that exec always fails with exit status 2 regardless
    of what it actually returns.
    
    This patch adds the missing check for EXEXEC so that the correct
    exit status is preserved.
    
    Signed-off-by: Herbert Xu <herb...@gondor.apana.org.au>

diff --git a/ChangeLog b/ChangeLog
index 1dfe241..2faaedd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-10-07  Herbert Xu <herb...@gondor.apana.org.au>
+
+       * Fix EXEXEC status clobbering.
+
 2010-09-08  Herbert Xu <herb...@gondor.apana.org.au>
 
        * Fix ifsfirst/ifslastp leak.
diff --git a/src/eval.c b/src/eval.c
index 5b8d36b..b966749 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -854,7 +854,7 @@ bail:
                        int i;
 
                        i = exception;
-                       if (i == EXEXIT)
+                       if (i == EXEXIT || i == EXEXEC)
                                goto raise;
 
                        status = (i == EXINT) ? SIGINT + 128 : 2;

Thanks,
-- 
Email: Herbert Xu <herb...@gondor.apana.org.au>
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

Reply via email to