Restore compatibility with GNU diff regarding --label
Various options to "diff(1)" show filenames, and traditionally make use of the "--label" parameter, if set. Restore this behaviour in BSD diff. While here add a regression test PR: 244533 Submitted by: Jamie Landeg-Jones <jamie@catflap.org> MFC after: 3 days
This commit is contained in:
parent
f6287cc63c
commit
f096ed981f
@ -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",
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user