The R Project SVN R

Rev

Rev 22506 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22506 Rev 23041
1
#! /bin/sh
1
#! /bin/sh
2
##
2
##
3
## Rdiff -- Diff 'without R version'
3
## Rdiff -- Diff 'without R version'
4
 
4
 
5
## Usage:
5
## Usage:
6
##   R CMD Rdiff from-file to-file exitstatus
6
##   R CMD Rdiff from-file to-file exitstatus
7
## where from-file equal to '-' means STDIN
7
## where from-file equal to '-' means STDIN
8
 
8
 
9
ffile=${1}
9
ffile=${1}
10
tfile=${2}
10
tfile=${2}
11
exitstatus=${3}
11
exitstatus=${3}
12
 
12
 
13
## sed script to get rid of the startup message
13
## sed script to get rid of the startup message
14
script='/^R : Copyright/,/quit R.$/{d;}'
14
script='/^R : Copyright/,/quit R.$/{d;}'
15
## egrep pattern to get rid of some more???
15
## egrep pattern to get rid of some more???
16
pattern='(^Number of.*:|^Time |^Loading required package.*'
16
pattern='(^Number of.*:|^Time |^Loading required package.*'
17
case "${ffile}" in
17
case "${ffile}" in
18
  *primitive-funs*)
18
  *primitive-funs*)
19
    pattern=${pattern}'|^\[1\] [19][0-9][0-9])'
19
    pattern=${pattern}'|^\[1\] [19][0-9][0-9])'
20
    ;;
20
    ;;
21
  *)
21
  *)
22
    pattern=${pattern}')'
22
    pattern=${pattern}'|^<environment)'
23
    ;;
23
    ;;
24
esac  
24
esac  
25
 
25
 
26
tmpfile=${TMPDIR-/tmp}/${ffile}-d.${$}
26
tmpfile=${TMPDIR-/tmp}/${ffile}-d.${$}
27
 
27
 
28
if test ${ffile} = '-' ; then 
28
if test ${ffile} = '-' ; then 
29
  ffile=''
29
  ffile=''
30
fi
30
fi
31
 
31
 
32
sed -e "${script}" ${ffile} | ${EGREP} -v "${pattern}" > ${tmpfile}
32
sed -e "${script}" ${ffile} | ${EGREP} -v "${pattern}" > ${tmpfile}
33
(sed -e "${script}" ${tfile} | \
33
(sed -e "${script}" ${tfile} | \
34
  ${EGREP} -v "${pattern}" | \
34
  ${EGREP} -v "${pattern}" | \
35
  diff -bw ${tmpfile} - ) && exitstatus=0
35
  diff -bw ${tmpfile} - ) && exitstatus=0
36
 
36
 
37
rm -f ${tmpfile}
37
rm -f ${tmpfile}
38
 
38
 
39
exit ${exitstatus}
39
exit ${exitstatus}