Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: jono.chadwell@gmail.com Newsgroups: gnu.bash.bug Subject: Writing to /dev/stderr overwrites xtrace data Date: Wed, 30 Oct 2019 18:10:23 -0700 (PDT) Lines: 43 Approved: bug-bash@gnu.org Message-ID: References: <20191031011023.B4AC1E0051@birch.ghs.com> NNTP-Posting-Host: lists.gnu.org X-Trace: usenet.stanford.edu 1572488211 9053 209.51.188.17 (31 Oct 2019 02:16:51 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org,bash@packages.debian.org Envelope-to: bug-bash@gnu.org X-ASG-Debug-ID: 1572484223-05da202b895eeb0001-S1qaIM X-Barracuda-Envelope-From: chadwell@ghs.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.64.231 X-Barracuda-RBL-IP: 192.168.107.246 X-ASG-Orig-Subj: Writing to /dev/stderr overwrites xtrace data X-Barracuda-Connect: allegro.ghs.com[192.168.64.231] X-Barracuda-Start-Time: 1572484223 X-Barracuda-URL: https://192.168.64.230:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ghs.com X-Barracuda-Scan-Msg-Size: 1645 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 1.50 X-Barracuda-Spam-Status: No, SCORE=1.50 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests=BSF_SC0_MV1001, NO_REAL_NAME X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.77704 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 NO_REAL_NAME From: does not include a real name 1.50 BSF_SC0_MV1001 Custom rule MV1001 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.234.187.110 X-Mailman-Approved-At: Wed, 30 Oct 2019 22:16:48 -0400 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <20191031011023.B4AC1E0051@birch.ghs.com> Xref: csiph.com gnu.bash.bug:15546 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 -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall uname output: Linux birch 4.15.0-65-generic #74~16.04.1-Ubuntu SMP Wed Sep 18 09:51:44 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 4.3 Patch Level: 48 Release Status: release Description: I enabled xtrace to try and debug a bash script running on a validation server. The script stored its stdout and stderr to a log file. I expected to see trace data in the log file, but instead found a single log statement, a bunch of NULL bytes, and the line '+ exit 1'. After some playing around with it I found that writing to the file /dev/stderr was responsible for deleting the xtrace data. Repeat-By: ``` echo "#!/usr/bin/env bash" > script.sh echo "set -o xtrace" >> script.sh echo "echo to_stderr > /dev/stderr" >> script.sh chmod 755 script.sh ./script.sh 2> stderr_output ``` After running these commands I expect to see find xtrace output in stderr_output. Instead I only see 'to_stderr\n'. If this behavior is unavoidable due to how linux file IO, then I recommend at least adding the documentation as a known gotcha. Thanks, Jono Chadwell