Bug 8196

Summary: diff fifo1 fifo2 always returns 0
Product: Busybox Reporter: michael fox <415fox>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.23.x   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:

Description michael fox 2015-07-04 11:53:36 UTC
Switching to BusyBox diff:

    sh$ mkfifo fifo
    sh$ echo foo > fifo &
    sh$ echo bar | diff fifo -
    sh$ echo $?
    0

Or:

    sh$ mkfifo fifo fifo2
    sh$ echo foo > fifo &
    sh$ echo bar > fifo2 &
    sh$ diff fifo fifo2
    sh$ echo $?
    0

Thanks to xz-utils developer Lasse Collin for these examples.
Comment 1 michael fox 2015-07-04 14:52:20 UTC
I wanted to work on this but some nice person me to it. :( Confirmed fixed in master branch. Here's some added tests if anyone wants them.

diff --git a/testsuite/diff.tests b/testsuite/diff.tests
index 6de4648..fdde7cd 100755
--- a/testsuite/diff.tests
+++ b/testsuite/diff.tests
@@ -214,4 +214,35 @@ SKIP=
 # clean up
 rm -rf diff1 diff2
 
+mkfifo fifo1 fifo2
+echo qwe >fifo1 &
+echo rty >fifo2 &
+testing "diff of two fifos" \
+       "diff -u fifo1 fifo2 | $TRIM_TAB;" \
+"\
+--- fifo1
++++ fifo2
+@@ -1 +1 @@
+-qwe
++rty
+" \
+       "" ""
+SKIP=
+
+echo qwe >fifo1 &
+testing "diff fifo and stdin" \
+       "diff -u fifo1 - | $TRIM_TAB;" \
+"\
+--- fifo1
++++ -
+@@ -1 +1 @@
+-qwe
++rty
+" \
+       "" "rty\n"
+SKIP=
+
+# clean up
+rm -rf fifo1 fifo2
+
 exit $FAILCOUNT