diff: fix a bug in diffing against stdin. Closes 7784
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
70f4320b40
commit
39f017293a
@ -740,9 +740,10 @@ static int diffreg(char *file[2])
|
|||||||
unlink(name);
|
unlink(name);
|
||||||
if (bb_copyfd_eof(fd, fd_tmp) < 0)
|
if (bb_copyfd_eof(fd, fd_tmp) < 0)
|
||||||
xfunc_die();
|
xfunc_die();
|
||||||
if (fd) /* Prevents closing of stdin */
|
if (fd != STDIN_FILENO)
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = fd_tmp;
|
fd = fd_tmp;
|
||||||
|
xlseek(fd, 0, SEEK_SET);
|
||||||
}
|
}
|
||||||
fp[i] = fdopen(fd, "r");
|
fp[i] = fdopen(fd, "r");
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,17 @@ testing "diff of stdin, twice" \
|
|||||||
"" \
|
"" \
|
||||||
"stdin"
|
"stdin"
|
||||||
|
|
||||||
|
testing "diff of empty file against stdin" \
|
||||||
|
"diff -u - input | $TRIM_TAB" \
|
||||||
|
"\
|
||||||
|
--- -
|
||||||
|
+++ input
|
||||||
|
@@ -1 +0,0 @@
|
||||||
|
-a
|
||||||
|
" \
|
||||||
|
"" \
|
||||||
|
"a\n"
|
||||||
|
|
||||||
testing "diff of empty file against nonempty one" \
|
testing "diff of empty file against nonempty one" \
|
||||||
"diff -u - input | $TRIM_TAB" \
|
"diff -u - input | $TRIM_TAB" \
|
||||||
"\
|
"\
|
||||||
|
Loading…
Reference in New Issue
Block a user