"bash -c 'exit 5'" gives 127 !

"bash -c 'exit 5'" gives 127 !

Post by Felix von Leitn » Mon, 20 Mar 1995 00:08:08



Hi Folks !

While trying to compile Andrew and some other large projects with huge
makefile systems using /bin/sh under Linux (where /bin/sh is bash), I
found this strange behaviour :

  $ sh -c 'exit 5' ; echo $?
  127
  $

This broke all makefiles using "sh -c".  So I began tracing this in bash
and found that it is no bug, it's a features ;)  At least it looks like
it was meant this way.  But I find it not only strange, I find it wrong.
Under all other Unixes I could try it on, it worked like expected,
returning 5.  Well, if somebody else wants to correct this in
bash-1.14.3, this is the diff for shell.c

Felix

---
1036d1035
<    case EXITPROG:
1037a1037,1038

Quote:>    case EXITPROG:
>      return last_command_exit_value;

---

--
If Rush Limbaugh doesn't need a disclaimer, neither do I.
"Who is General Failure and why is he reading my hard disk ?"
  Microsoft spel chekar vor sail, worgs grate !!

--

PLEASE remember Keywords: and a short description of the software.

 
 
 

1. "bash -c 'exit 5'" gives 127 !


   Hi Folks !

   While trying to compile Andrew and some other large projects with huge
   makefile systems using /bin/sh under Linux (where /bin/sh is bash), I
   found this strange behaviour :

     $ sh -c 'exit 5' ; echo $?
     127
     $

Very interesting!

On our systems here (HP/UX 9000/7xx):

[295] late5 % bash -version
GNU bash, version 1.13.2-CWRU
[257] late5 % bash -c 'exit 5'; echo $?
5

But there still seem to be many other interesting "features" in bash!

--
Bernd Anhaeupl                  Tel.:  +49 9131 857787
LATE - Uni Erlangen                    

91058 Erlangen

2. 256 slot serial board

3. What is this supposed to return: "trap 'exit ' 0; exit"?

4. ?Name of Spreadsheet for SCO, runs w/ibcs

5. FlexFax: Can not reach "fax" service at host "127.0.0.1"

6. Scheduler ( was: Just a second ) ...

7. Cygwin bash "id -un" returns "Administrator" when I'm not

8. Wierd!! Random `<' characters on current VC!

9. """"""""My SoundBlast 16 pnp isn't up yet""""""""""""

10. Why doesn't echo "text" 'command' "more text" work?

11. trap "action; exit" signals = trap "action" exit?

12. WHY 'exec "$REALFILE" ${1+"$@"}'