Dear Maintainer,
While trying to suppress the "Aborted" message given by the shell when a
command exits on SIGABRT, I came to the following test script:
====[ filter_aborted.sh ]=============================================
#!/bin/dash
echo "Test #1"
(
./abort 2>&3 || exit $?
) 3>&2 2> /dev/null
echo "=> $?"
echo "Test #2"
(
( exec ./abort ) 2>&3 || exit $?
) 3>&2 2> /dev/null
echo "=> $?"
======================================================================
The "abort" command simply outputs a simple message on stdout and
stderr, and then aborts with SIGABRT. Its C source is given bellow.
====[ abort.c ]=======================================================
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
fputs("1 on stdout\n", stdout);
fflush(stdout);
fputs("2 on stderr\n", stderr);
fflush(stderr);
abort();
}
======================================================================
I was expecting to get the same visible result for both tests (#1 and #2
in the script), i.e. see the simple messages from the "abort" command,
but the "Aborted" message from the shell redirected to /dev/null.
This only works for the second case (Test #2) where a double subshell is
used. Note that it works as expected with "bash --posix".
Sample output :
$ ./filter_aborted.sh
Test #1
1 on stdout
2 on stderr
Aborted (core dumped)
=> 134
Test #2
1 on stdout
2 on stderr
=> 134
Regards,
Arnaud Giersch