The R Project SVN R

Rev

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

Rev 23041 Rev 32349
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}'|^<environment)'
22
    pattern=${pattern}'|^<environment)'
23
    ;;
23
    ;;
24
esac  
24
esac
25
 
25
 
26
tmpfile=${TMPDIR-/tmp}/${ffile}-d.${$}
-
 
27
 
-
 
28
if test ${ffile} = '-' ; then 
26
if test ${ffile} = '-' ; then
29
  ffile=''
27
  ffile=''
-
 
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
30
fi
36
fi
31
 
37
 
-
 
38
tmpfile=${TMPDIR-/tmp}/${bfile}-d.${$}
-
 
39
 
32
sed -e "${script}" ${ffile} | ${EGREP} -v "${pattern}" > ${tmpfile}
40
sed -e "${script}" ${ffile} | ${EGREP} -v "${pattern}" > ${tmpfile}
33
(sed -e "${script}" ${tfile} | \
41
(sed -e "${script}" ${tfile} | \
34
  ${EGREP} -v "${pattern}" | \
42
  ${EGREP} -v "${pattern}" | \
35
  diff -bw ${tmpfile} - ) && exitstatus=0
43
  diff -bw ${tmpfile} - ) && exitstatus=0
36
 
44
 
37
rm -f ${tmpfile}
45
rm -f ${tmpfile}
38
 
46
 
39
exit ${exitstatus}
47
exit ${exitstatus}