Bug 90960 - diff file1 file2 ... filen directory
diff file1 file2 ... filen directory
Status: CLOSED WONTFIX
Product: Red Hat Linux
Classification: Retired
Component: diffutils (Show other bugs)
7.1
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
Mike McLean
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-05-15 15:40 EDT by John Dalbec
Modified: 2007-04-18 12:53 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-05-16 06:08:03 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description John Dalbec 2003-05-15 15:40:23 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2)
Gecko/20030208 Netscape/7.02

Description of problem:
Would it be possible to extend the "diff" utility to operate like "mv" and "cp"
in the above situation?  The output should be similar to the output of "diff
directory1 directory2".  The files "file1" ... "filen" should be compared to the
files of the same names in the directory "directory".  Any other files in the
directory "directory" should be ignored.  If POSIX forbids this, could another
utility be created that works like "diff" but has this feature?

Version-Release number of selected component (if applicable):


How reproducible:
Didn't try

Steps to Reproduce:
1. diff file1 file2 directory

    

Actual Results:  error message

Expected Results:  file1 should be compared to directory/`basename file1`.  If
they differ, the equivalent "diff" command should be printed followed by normal
"diff" output.
file2 should be compared to directory/`basename file2`.  If they differ, the
equivalent "diff" command should be printed followed by normal "diff" output.
directory/file3 should be ignored, i.e., no "Only in directory: file3" message
should be printed.

Additional info:

You can sort of do this by copying the requested files and their partners in the
requested directory to temporary directories and then running "diff tmpdir1
tmpdir2" but then the "diff" lines will have tmpdir1 and tmpdir2 instead of the
original locations of the files.  Plus it seems wasteful to do more file copying
than strictly necessary.
Comment 1 Tim Waugh 2003-05-16 06:08:03 EDT
This isn't hard to do in a few lines of shell:

#!/bin/bash
TMPDIR=$(mktemp -d mydiff.XXXXXX) || exit 1
FILES=("$@")
DIR=${FILES[$(($# - 1))]}
unset FILES[$(($# - 1))]
cp -l ${FILES[@]} "$TMPDIR"
diff -ur "$TMPDIR" "$DIR" | \
        filterdiff --strip=1 --addprefix=$(dirname "$DIR/.")/
rm -rf "$TMPDIR"

It's not something we're likely to add to diffutils I'm afraid, since for one
thing it makes the meaning of several of the options much less clear-cut.  Feel
free to discuss it with the upstream maintainer of diffutils of course.
Comment 2 John Dalbec 2003-06-20 15:50:42 EDT
diffutils 2.7.2 has the "--to-file" option which allows
diff file1 file2 file3 --to-file=directory

Note You need to log in before you can comment on or make changes to this bug.