summaryrefslogtreecommitdiff
path: root/usr.bin/diff
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2020-06-01 09:01:13 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2020-06-01 09:01:13 +0000
commitf096ed981fe534c36ed8662ef307042123e443f3 (patch)
tree468ecf1a4da36b4c2708c64d1775f63a3085da91 /usr.bin/diff
parentf6287cc63c7283ef4b789b5ff1b8fe24660f8073 (diff)
downloadsrc-test2-f096ed981fe534c36ed8662ef307042123e443f3.tar.gz
src-test2-f096ed981fe534c36ed8662ef307042123e443f3.zip
Notes
Diffstat (limited to 'usr.bin/diff')
-rw-r--r--usr.bin/diff/diff.c3
-rwxr-xr-xusr.bin/diff/tests/diff_test.sh13
2 files changed, 16 insertions, 0 deletions
diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c
index 7755419f2a45..82e60c953a67 100644
--- a/usr.bin/diff/diff.c
+++ b/usr.bin/diff/diff.c
@@ -465,6 +465,9 @@ print_only(const char *path, size_t dirlen, const char *entry)
void
print_status(int val, char *path1, char *path2, const char *entry)
{
+ if (label[0] != NULL) path1 = label[0];
+ if (label[1] != NULL) path2 = label[1];
+
switch (val) {
case D_BINARY:
printf("Binary files %s%s and %s%s differ\n",
diff --git a/usr.bin/diff/tests/diff_test.sh b/usr.bin/diff/tests/diff_test.sh
index 6f4b484b3a37..3a3883540e8c 100755
--- a/usr.bin/diff/tests/diff_test.sh
+++ b/usr.bin/diff/tests/diff_test.sh
@@ -12,6 +12,7 @@ atf_test_case b230049
atf_test_case Bflag
atf_test_case tabsize
atf_test_case conflicting_format
+atf_test_case label
simple_body()
{
@@ -195,6 +196,17 @@ conflicting_format_body()
atf_check -s exit:1 -o ignore -e ignore diff --normal --normal A B
}
+label_body()
+{
+ printf "\tA\n" > A
+
+ atf_check -o inline:"Files hello and world are identical\n" \
+ -s exit:0 diff --label hello --label world -s A A
+
+ atf_check -o inline:"Binary files hello and world differ\n" \
+ -s exit:1 diff --label hello --label world `which diff` `which ls`
+}
+
atf_init_test_cases()
{
atf_add_test_case simple
@@ -209,4 +221,5 @@ atf_init_test_cases()
atf_add_test_case Bflag
atf_add_test_case tabsize
atf_add_test_case conflicting_format
+ atf_add_test_case label
}