Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../. -I.././include -I.././lib -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall uname output: Linux apps0 3.13.0-65-generic #106-Ubuntu SMP Fri Oct 2 22:08:27 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu
Bash Version: 4.3 Patch Level: 11 Release Status: release Description: If Bash writes to stdout with the built in echo and gets a SIGPIPE, it can incorrectly buffer and then repeat this would-have-been output in at least $(...) things invoked in a cleanup function and in fact in some other contexts as well. To see this in action, create the following script as /tmp/repro: #!/bin/bash function cleanup() { r1=$(/bin/echo one) r2=$(/bin/echo two) echo $r1 '!' $r2 1>&2 #echo $r1 '!' $r2 >>/tmp/logout } trap cleanup EXIT sleep 1 echo final Run it as '/tmp/repro | false'. The output produced is the clearly incorrect: $ /tmp/repro | false final one final ! two final If you switch the 'echo' to the commented out version, the bare 'final' disappears but the other two remain. Although I am filing this bug report from an Ubuntu 14.04 LTS machine, this issue also reproduces with the Fedora 22 and Fedora 23 versions of 'version 4.3.42(1)-release' and probably on other versions as well. For your potential reference, the original issue that uncovered this problem is covered here: https://github.com/golang/go/issues/13789