Thread View: gnu.bash.bug
2 messages
2 total messages
Started by James Van Artsdalen
Tue, 13 Jun 1989 17:51
ksh's trap "" ERR
Author: James Van Artsdalen
Date: Tue, 13 Jun 1989 17:51
Date: Tue, 13 Jun 1989 17:51
26 lines
1205 bytes
1205 bytes
On feature I miss from ksh is 'trap "" ERR'. For example, my .ksh file has trap 'echo "(ERR:$?)"' ERR I tried to simulate this in bash with PROMPT_COMMAND, but it didn't work. Here's an emacs M-x shell script: it starts out in ksh, and then runs bash. /tmp> (exit 1) (ERR:1) /tmp> /usr/local/src/dist-bash/bash /tmp> PROMPT_COMMAND='if [ $? -ne 0 ] ; then echo "(ERR:$?)" ; fi' PPROMPT_COMMAND='if [ $? -ne 0 ] ; then echo "(ERR:$?)" ; fi' /tmp> /tmp> (exit 1) ((exit 1) /tmp> bash doesn't print the error status. Also note that bash doesn't behave well under emacs, but I assume this is related to previous reported bugs with determining interactive status. -- James R. Van Artsdalen james@bigtex.cactus.org "Live Free or Die" Dell Computer Co 9505 Arboretum Blvd Austin TX 78759 512-338-8789
ksh's trap "" ERR
Author: composer
Date: Tue, 13 Jun 1989 22:03
Date: Tue, 13 Jun 1989 22:03
53 lines
2226 bytes
2226 bytes
| Date: 13 Jun 89 17:51:14 GMT
| From: milano!bigtex!james@cs.utexas.edu (James Van Artsdalen)
|
| On feature I miss from ksh is 'trap "" ERR'. For example, my .ksh
| file has
|
| trap 'echo "(ERR:$?)"' ERR
|
| I tried to simulate this in bash with PROMPT_COMMAND, but it didn't
| work. Here's an emacs M-x shell script: it starts out in ksh, and
| then runs bash.
|
| /tmp> (exit 1)
| (ERR:1)
| /tmp> /usr/local/src/dist-bash/bash
| /tmp> PROMPT_COMMAND='if [ $? -ne 0 ] ; then echo "(ERR:$?)" ; fi'
| PROMPT_COMMAND='if [ $? -ne 0 ] ; then echo "(ERR:$?)" ; fi'
| /tmp>
|
| /tmp> (exit 1)
| (exit 1)
| /tmp>
|
| bash doesn't print the error status. Also note that bash doesn't
| behave well under emacs, but I assume this is related to previous
| reported bugs with determining interactive status.
You had the right idea. The problem (I believe) with your emulation is
that the status ($?) gets reset after the test. You could set up a
function to do the same thing as follows:
function ERR () {
local err=$?
if [ $? -ne 0 ]; then
echo "(ERR:err)"
fi
}
and then set PROMPT_COMMAND=ERR
That should work. Actually, there seems to be a problem with the return
status from a subshell not getting returned properly. Or, is it supposed
to? Haven't looked into it yet. But, "(exit 1)" was returning 0. There
also may be better methods of doing this, but I was just taking what you
had already presented. Enjoy...
| James R. Van Artsdalen james@bigtex.cactus.org "Live Free or Die"
| Dell Computer Co 9505 Arboretum Blvd Austin TX 78759 512-338-8789
-jeff
Jeff Kellem
INTERNET: composer@bu-cs.bu.edu (or composer%bu-cs.bu.edu@bu-it.bu.edu)
UUCP: ...!harvard!bu-cs!composer
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads