Package: dash Version: 0.5.5.1-3 Severity: wishlist Steps to reproduce: 1) cat > testcase1.sh <<EOF #!/bin/sh ( set -x i=`echo f|cut -d' ' -f4|sort` ) 2>&1 EOF 2) ensure that /bin/sh is dash 3) while true; do ./testcase1.sh > a; grep cut a; done
Expected results: 3) since echo, cut and sort are deterministic the output of this program should be determistic too and always just print + cut -d -f4 Actual results: 3) The output of the program seems to be quite non-deterministic: + cut -d -f4 + cut -d -f4 cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 cut -d -f4 + cut -d -f4 cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 + cut+ d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 cut -d -f4 + cut -d -f4 cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 cut -d -f4 + cut -d -f4 + cut -d -f4 cut -d -f4 + cut -d -f4 cut -d -f4 cut -d -f4 + cut -d -f4 cut -d -f4 cut -d -f4 cut -d -f4 cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4sort cut -d -f4 + cut -d -f4 cut -d -f4 cut -d -f4 cut -d -f4 cut -d -f4 + cut -d -f4 + cut -d -f4sort + cut -d -f4sort + cut -d -f4sort cut -d -f4 + + cut -d -f4 + cut -d -f4 cut -d -f4 + cut -d -f4sort + cut -d -f4sort + cut -d -f4 cut -d -f4 + cut -d -f4 cut -d -f4 + cut -d -f4 cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4 + cut -d -f4sort + cut -d -f4 + cut -d -f4 + cut -d -f4 More info: 1) I do not know if this behavior is a bug or not but I think it at least should be documented in the manual page. 2) I built dash git revision 72811e307d07c8e5902a7f73ea6491eabb93a4ce and was able to reproduce the behavior with it. 3) Suggested improvement to manual page: diff --git a/src/dash.1 b/src/dash.1 index c7771d0..82b8c8e 100644 --- a/src/dash.1 +++ b/src/dash.1 @@ -228,6 +228,11 @@ Write each command to standard error (preceded by a .Sq +\ ) before it is executed. Useful for debugging. +However, note that debugging output from +subshells can get mixed with parent's debugging output in a +non-deterministic fashion. This can lead to lines with two +.Sq \+ +prefixes or no prefixes at all. .It Fl I Em ignoreeof Ignore EOF's from input when interactive. .It Fl i Em interactive 4) Non-determinism is a problem when one wants to compare huge "set -x logs" of a program P on machines A and B to figure out why P works on A but does not work on B. It took me a long time to figure out that if I run the program multiple times I sometimes get different results. 5) This non-determinism also happens on a non-SMP armel system so it is not related to SMP. 6) If the whole line was printed with a single syscall the probability of getting mixed lines would be much lower (bash seems to print the whole line with a single syscall but dash apparently tries to save memory by printing it in small pieces). -- System Information: Debian Release: squeeze/sid APT prefers testing APT policy: (500, 'testing') Architecture: amd64 (x86_64) Kernel: Linux 2.6.32-trunk-amd64 (SMP w/2 CPU cores) Locale: LANG=C, LC_CTYPE=fi_FI (charmap=ISO-8859-1) Shell: /bin/sh linked to /bin/dash Versions of packages dash depends on: ii debianutils 3.2.2 Miscellaneous utilities specific t ii dpkg 1.15.5.6 Debian package management system ii libc6 2.10.2-2 GNU C Library: Shared libraries dash recommends no packages. dash suggests no packages. -- debconf information: dash/sh: true -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org