[comp.unix.questions] sh -ce

marc@ibmpa.awdpa.ibm.com (Marc Pawliger) (02/14/91)

The man page for sh and ksh say the -e flag causes immediate exit if a command
fails.  Does this also apply for builtins?  And what about the exit status?

I have seen vastly differing behavior for the following:

  /bin/sh -ce 'cd nonexistantdirectory; pwd'

Some Bourne shells exit after the bad cd with status 0, some exit with status
1.  Some don't exit after the bad cd, presumably because it's a builtin.
/bin/sh -ce '/bin/ls nonexistantdirectory; pwd' always exited after the ls
with status 1.

Please also reply by mail if you are following-up in this group...

+--Marc Pawliger----IBM Advanced Workstations Division----Palo Alto, CA---+
|   Internet: marc@ibminet.awdpa.ibm.com        VNET:    MARCP at AUSVM6  |
|    UUCP:     uunet!ibminet.awdpa.ibm.com!marc  Phone:   (415) 855-3493  |
+-----IBMinet:  marc@ibmpa.awdpa.ibm.com----------IBM T/L:  465-3493------+

As always, these are my opinions and not IBM's etc etc etc