This file is indexed.

/usr/bin/cvsmgdiff is in mgdiff 1.0-30+b1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#! /bin/bash

#
# This script lets you recursively diff the CVS directories you have
# checked out.  To use, just pass in an optional revision levels and
# an optional file directory name.  This script then will show you the
# differences you're interested in.
#
#                                             -- Paul Serice
#

CVSMGDIFF_VERSION=1.1

: ${MGDIFF:=/usr/bin/mgdiff}
: ${TMP:=/tmp}

function usage {
    if [ $# -ne 1 ] ; then
        echo "progname: Error: Invalid args for usage: \"$@\"" >&2
        exit 1
    fi
    cmd=
    cmd="$cmd echo >&2 ;"
    cmd="$cmd echo \"Usage: $progname [-h] [-v]"
    cmd="$cmd [-g <gui>] [[-r <rev1>] [-r <rev2>]] file\" >&$1 ;"
    cmd="$cmd echo >&2"
    eval "$cmd"
    if [ $1 -eq 1 ] ; then
        exit 0
    fi
    exit 1
}

function verify_exec {
    if [ $# -ne 1 ] ; then
        echo "$progname: Error: Invalid args for verify_exec: \"$@\"" >&2
        exit 1
    fi
    if ! type "$1" >/dev/null 2>&1 ; then
        echo "$progname: Error: Unable to find executable for \"$1\"." >&2
        exit 1
    fi
}

tmp_base="cvsmgdiff-$$."
function clean_up {
    # These signal handlers are rough.  It is, as far as I can tell,
    # impossible to pass in the name of the currently active temporary
    # files.  A reasonable alternative is to scan $TMP for files that
    # match the pattern we use being careful not to allow a malicious
    # user to trick us into deleting some other file.
    find "$TMP" -maxdepth 1 \
                -type f \
                -links 1 \
                -uid `id -u` \
                -name "$tmp_base"'*' \
                -print0 \
    | xargs -r0 rm -f
    exit 0
}

#
# getunique() -- Finds two unique temporary file names.
#
getunique()
{
    old_umask=`umask`
    umask 077
    if ! tmp_file_1=$(mktemp -q "$TMP/${tmp_base}XXXXXX") ; then
        echo "Error: Unable to allocate a necessary temporary file." >&2
        exit 1
    fi
    
    if ! tmp_file_2=$(mktemp -q "$TMP/${tmp_base}XXXXXX") ; then
        echo "Error: Unable to allocate a necessary temporary file." >&2
        exit 1
    fi
    umask $old_umask
}

#
# Script Starts Here !!!
#

progname="cvsmgdiff.sh"
verify_exec "basename"
progname=`basename $0`

# Signal Trap handler to clean up temporary files in "$TMP".
if ! trap 'clean_up' HUP INT QUIT TERM ; then
    echo "$progname: Unable to register signal handler." >&2
    exit 1
fi

# Get cvs revision(s) to use.
cnt=0
while getopts "g:hr:v" OPT ; do
    case "$OPT" in
        g)  MGDIFF="$OPTARG"
            ;;
        h)  usage 1
            ;;
        r)  rev[$cnt]="-r$OPTARG"
            cnt=`expr $cnt + 1`
            ;;
        v)  echo "$progname: ${CVSMGDIFF_VERSION}"
            exit 0
            ;;
        \?) usage 2
            ;;
    esac
done
shift `expr $OPTIND - 1`

verify_exec "cut"
verify_exec "cvs"
verify_exec "echo"
verify_exec "expr"
verify_exec "find"
verify_exec "grep"
verify_exec "$MGDIFF"
verify_exec "mktemp"
verify_exec "sleep"
verify_exec "xargs"

mgdiff_basename=`basename "$MGDIFF"`

# Portability issues.
if [ "$mgdiff_basename" = "mgdiff" ] ; then
    QUIET_OPT="-quit"
    FNAME_OPT="-file"
elif [ "$mgdiff_basename" = "xdiff" ] ; then
    QUIET_OPT="-D"
    FNAME_OPT="-N"
elif [ "$mgdiff_basename" = "xxdiff" ] ; then
    QUIET_OPT="-D"
    FNAME_OPT="-N"
    TITLE_1_OPT="--title1"
    TITLE_2_OPT="--title2"
fi

if [ $cnt -gt 2 ] ; then
    echo
    echo "Error: Too many revisions."
    echo
    exit 1
fi

if [ ! -d `pwd`"/CVS" ] && [ ! -d `pwd`"/$1/CVS" ] ; then
    echo
    echo "Warning: \"$1\" does not appear to be a CVS directory." 1>&2
    echo "Trying to diff \"$1\" with CVS repository anyway."
    echo
    sleep 5
fi

# Run CVS recursively on the entire directory.
cvs diff "${rev[@]}" "$@" 2>/dev/null \
| grep '^Index:' \
| cut -d ' ' -f 2 \
| while read fname ; do

      echo -n "Processing $fname . . . "

      # tkdiff CVS access built-in.
      if [ "$mgdiff_basename" = "tkdiff" ] ; then

          "$MGDIFF" ${rev[0]+"${rev[@]}"} "$fname"

      # The others require a little bit of scripting.
      elif [ $cnt -eq 2 ] ; then

          getunique

          \cvs update -p "${rev[0]}" "$fname" > "$tmp_file_1" 2> /dev/null
          \cvs update -p "${rev[1]}" "$fname" > "$tmp_file_2" 2> /dev/null

          "$MGDIFF" ${QUIET_OPT+"$QUIET_OPT"} \
                    ${TITLE_1_OPT+"$TITLE_1_OPT" "$fname (rev ${rev[0]#-r})"} \
                    ${TITLE_2_OPT+"$TITLE_2_OPT" "$fname (rev ${rev[1]#-r})"} \
                    "$tmp_file_1" "$tmp_file_2"

          \rm -f "$tmp_file_1" > /dev/null 2>&1
          \rm -f "$tmp_file_2" > /dev/null 2>&1
          
      elif [ $cnt -le 1 ] ; then

         if [ $cnt -eq 1 ] ; then
             title_rev="${rev[0]#-r}"
         else
             title_rev=`cvs status "$fname" \
                        | grep 'Working revision:' \
                        | awk '{print $3;}'`
         fi
              
          # For some reason, xxdiff does not like to work with pipes
          # despite its saying otherwise.
          if [ "$TITLE_1_OPT" ] ; then

              getunique

              # The convention that "diff" uses is that the old file is on
              # the left and the new file is on the right.  We use this to
              # display the files for all but "mgdiff" which has a
              # "File->Save As..." menu option that works better the other
              # way around.
              file_first="$tmp_file_1"
              file_second="$fname"
              if [ "$mgdiff_basename" = "mgdiff" ] ; then
                  file_first="$fname"
                  file_second="$tmp_file_1"
              fi

              cvs update -p ${rev[0]+"${rev[0]}"} "$fname" \
                     > "$tmp_file_1" 2>/dev/null
              
              "$MGDIFF" ${QUIET_OPT+"$QUIET_OPT"} \
                        ${TITLE_1_OPT+"$TITLE_1_OPT" "$fname (rev $title_rev)"}\
                        "$file_first" "$file_second"
              
              \rm -f "$tmp_file_1" > /dev/null 2>&1
              \rm -f "$tmp_file_2" > /dev/null 2>&1

          else

              # See comment above.
              file_first="-"
              file_second="$fname"
              if [ "$mgdiff_basename" = "mgdiff" ] ; then
                  file_first="$fname"
                  file_second="-"
              fi

              cvs update -p ${rev[0]+"${rev[0]}"} "$fname" 2>/dev/null \
              | "$MGDIFF" ${QUIET_OPT+"$QUIET_OPT"} \
                          ${FNAME_OPT+"$FNAME_OPT" "$fname (rev $title_rev)"} \
                          "$file_first" "$file_second"

          fi
          
      fi

      echo "Done."

  done