The R Project SVN R

Rev

Details | 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;}'
11358 hornik 15
## egrep pattern to get rid of some more???
11741 hornik 16
pattern='(^Number of.*:|^Time |^Loading required package.*'
22506 hornik 17
case "${ffile}" in
18
  *primitive-funs*)
19
    pattern=${pattern}'|^\[1\] [19][0-9][0-9])'
20
    ;;
21
  *)
32355 maechler 22
    pattern=${pattern}'|^<(environment|promise|pointer): )'
22506 hornik 23
    ;;
32349 maechler 24
esac
8746 hornik 25
 
32349 maechler 26
if test ${ffile} = '-' ; then
11476 maechler 27
  ffile=''
32349 maechler 28
  bfile=''
29
else
30
  if test -f ${ffile} ; then
31
      bfile=`basename "${ffile}"`
32
  else
33
      echo "no valid file ${ffile}"
34
      exit 1
35
  fi
11476 maechler 36
fi
37
 
32349 maechler 38
tmpfile=${TMPDIR-/tmp}/${bfile}-d.${$}
39
 
22506 hornik 40
sed -e "${script}" ${ffile} | ${EGREP} -v "${pattern}" > ${tmpfile}
11358 hornik 41
(sed -e "${script}" ${tfile} | \
22506 hornik 42
  ${EGREP} -v "${pattern}" | \
11358 hornik 43
  diff -bw ${tmpfile} - ) && exitstatus=0
44
 
8746 hornik 45
rm -f ${tmpfile}
11358 hornik 46
 
8746 hornik 47
exit ${exitstatus}