The R Project SVN R

Rev

Rev 43235 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 43235 Rev 45264
Line 1... Line 1...
1
#! /bin/sh
1
#! /bin/sh
2
##
2
##
3
## Rdiff -- Diff 'without R version'
3
## Rdiff -- diff 'without R version'
-
 
4
 
-
 
5
## Copyright (C) 2000-2008 The R Core Development Team.
-
 
6
## This is free software; see the GNU General Public License version 2
-
 
7
## or later for copying conditions.  There is NO warranty.
4
 
8
 
5
## Usage:
9
## Usage:
6
##   R CMD Rdiff from-file to-file exitstatus
10
##   R CMD Rdiff from-file to-file exitstatus
7
## where from-file equal to '-' means STDIN
11
## where from-file equal to '-' means STDIN
8
 
12
 
9
ffile=${1}
13
ffile=${1}
10
tfile=${2}
14
tfile=${2}
11
exitstatus=${3}
15
exitstatus=${3}
12
 
16
 
-
 
17
## These are set in Renviron if run from R CMD
-
 
18
## 'grep -E' is POSIX, but not AT&T Unix, so not supported
-
 
19
## by the default grep on Solarix, for example
-
 
20
EGREP=${EGREP-egrep}
-
 
21
SED=${SED-sed}
-
 
22
 
13
## sed scripts to get rid of the startup message
23
## sed scripts to get rid of the startup message
14
scriptold='/^R : Copyright /,/quit R.$/{d;}'
24
scriptold='/^R : Copyright /,/quit R.$/{d;}'
15
scriptnew='/^R version /,/quit R.$/{d;}'
25
scriptnew='/^R version /,/quit R.$/{d;}'
-
 
26
 
-
 
27
## turn UTF-8 directional single quotes into ASCII quote
16
s1="s/‘/'/g"
28
s1="s/‘/'/g"
17
s2="s/’/'/g"
29
s2="s/’/'/g"
18
 
30
 
19
## egrep pattern to get rid of some more
31
## egrep pattern to get rid of some more
20
## <= 2.2.x was pattern='(^Number of.*:|^Time |^Loading required package.*'
32
## <= 2.2.x was pattern='(^Number of.*:|^Time |^Loading required package.*'
Line 40... Line 52...
40
  fi
52
  fi
41
fi
53
fi
42
 
54
 
43
tmpfile=${TMPDIR-/tmp}/${bfile}-d.${$}
55
tmpfile=${TMPDIR-/tmp}/${bfile}-d.${$}
44
 
56
 
45
${SED-sed} -e "${scriptold}" -e "${scriptnew}" -e "${s1}" -e "${s2}" ${ffile} | ${EGREP} -v "${pattern}" > ${tmpfile}
57
${SED} -e "${scriptold}" -e "${scriptnew}" -e "${s1}" -e "${s2}" ${ffile} | ${EGREP} -v "${pattern}" > ${tmpfile}
46
## some packages ship .Rout.save with CRLF endings
58
## some packages ship .Rout.save with CRLF endings
47
(tr -d '\r' <  ${tfile} | ${SED-sed} -e "${scriptold}" -e "${scriptnew}" -e "${s1}" -e "${s2}" | \
59
(tr -d '\r' <  ${tfile} | ${SED} -e "${scriptold}" -e "${scriptnew}" -e "${s1}" -e "${s2}" | \
48
  ${EGREP} -v "${pattern}" | \
60
  ${EGREP} -v "${pattern}" | \
49
  diff -bw ${tmpfile} - ) && exitstatus=0
61
  diff -bw ${tmpfile} - ) && exitstatus=0
50
 
62
 
51
rm -f ${tmpfile}
63
rm -f ${tmpfile}
52
 
64