Rev 51510 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#!@R_SHELL@#### Rdiff -- diff 'without R version'revision='$Rev: 51510 $'version=`set - ${revision}; echo ${2}`version="R output diff: ${R_VERSION} (r${version})Copyright (C) 2000-2008 The R Core Development Team.This is free software; see the GNU General Public License version 2or later for copying conditions. There is NO warranty."usage="Usage: R CMD Rdiff FROM-FILE TO-FILE EXITSTATUSDiff R output files FROM-FILE and TO-FILE discarding the R startup message,where FROM-FILE equal to '-' means stdin.Options:-h, --help print this help message and exit-v, --version print version info and exitReport bugs to <r-bugs@r-project.org>."if test "${#}" -le 1; thencase "${1}" in-h | --help) echo "${usage}"; exit 0 ;;-v | --version) echo "${version}"; exit 0 ;;*) echo "${usage}"; exit 1 ;;esacfiffile=${1}tfile=${2}exitstatus=${3}## These are set in Renviron if run from R CMD## 'grep -E' is POSIX, but not AT&T Unix, so not supported## by the default grep on Solaris, for exampleEGREP=${EGREP-egrep}SED=${SED-sed}## sed scripts to get rid of the startup messagescriptold='/^R : Copyright /,/quit R.$/{d;}'scriptnew='/^R version /,/quit R.$/{d;}'## turn UTF-8 directional single quotes into ASCII quotes1="s/‘/'/g"s2="s/’/'/g"## egrep pattern to get rid of some morepattern='(^Time |^Loading required package.*|^Package [A-Za-z][A-Za-z0-9]+ loaded|^<(environment|promise|pointer): )'if test ${ffile} = '-' ; thenffile=''bfile=''elseif test -f ${ffile} ; thenbfile=`basename "${ffile}"`elseecho "no valid file ${ffile}"exit 1fifitmpfile=${TMPDIR-/tmp}/${bfile}-d.${$}${SED} -e "${scriptold}" -e "${scriptnew}" -e "${s1}" -e "${s2}" ${ffile} | ${EGREP} -v "${pattern}" > ${tmpfile}## some packages ship .Rout.save with CRLF endings## OTOH, Solaris's /usr/ucb/tr strips 'r' here(${TR} -d '\r' < ${tfile} | ${SED} -e "${scriptold}" -e "${scriptnew}" -e "${s1}" -e "${s2}" | \${EGREP} -v "${pattern}" | \diff -bw ${tmpfile} - ) && exitstatus=0rm -f ${tmpfile}exit ${exitstatus}