Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15546
| From | jono.chadwell@gmail.com |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Writing to /dev/stderr overwrites xtrace data |
| Date | 2019-10-30 18:10 -0700 |
| Message-ID | <mailman.60.1572488211.13325.bug-bash@gnu.org> (permalink) |
| References | <20191031011023.B4AC1E0051@birch.ghs.com> |
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
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Writing to /dev/stderr overwrites xtrace data jono.chadwell@gmail.com - 2019-10-30 18:10 -0700
csiph-web