Bug 8196 - diff fifo1 fifo2 always returns 0
Summary: diff fifo1 fifo2 always returns 0
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.23.x
Hardware: PC Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-04 11:53 UTC by michael fox
Modified: 2015-07-04 14:52 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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