The R Project SVN R

Rev

Rev 32355 | Rev 37742 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11358 hornik 1
#! /bin/sh
11515 hornik 2
##
22506 hornik 3
## Rdiff -- Diff 'without R version'
11358 hornik 4
 
22506 hornik 5
## Usage:
6
##   R CMD Rdiff from-file to-file exitstatus
7
## where from-file equal to '-' means STDIN
8
 
11358 hornik 9
ffile=${1}
10
tfile=${2}
8746 hornik 11
exitstatus=${3}
12
 
11358 hornik 13
## sed script to get rid of the startup message
11384 hornik 14
script='/^R : Copyright/,/quit R.$/{d;}'
37490 maechler 15
## egrep pattern to get rid of some more
16
## <= 2.2.x was pattern='(^Number of.*:|^Time |^Loading required package.*'
17
pattern='(^Time |^Loading required package.*'
22506 hornik 18
case "${ffile}" in
19
  *primitive-funs*)
20
    pattern=${pattern}'|^\[1\] [19][0-9][0-9])'
21
    ;;
22
  *)
32355 maechler 23
    pattern=${pattern}'|^<(environment|promise|pointer): )'
22506 hornik 24
    ;;
32349 maechler 25
esac
8746 hornik 26
 
32349 maechler 27
if test ${ffile} = '-' ; then
11476 maechler 28
  ffile=''
32349 maechler 29
  bfile=''
30
else
31
  if test -f ${ffile} ; then
32
      bfile=`basename "${ffile}"`
33
  else
34
      echo "no valid file ${ffile}"
35
      exit 1
36
  fi
11476 maechler 37
fi
38
 
32349 maechler 39
tmpfile=${TMPDIR-/tmp}/${bfile}-d.${$}
40
 
22506 hornik 41
sed -e "${script}" ${ffile} | ${EGREP} -v "${pattern}" > ${tmpfile}
11358 hornik 42
(sed -e "${script}" ${tfile} | \
22506 hornik 43
  ${EGREP} -v "${pattern}" | \
11358 hornik 44
  diff -bw ${tmpfile} - ) && exitstatus=0
45
 
8746 hornik 46
rm -f ${tmpfile}
11358 hornik 47
 
8746 hornik 48
exit ${exitstatus}