#!/bin/sh ##--- NEW: ---------- ## ## Given a list of files of the form .../.../.R, ## ## Produce one large file, i.e. write to stdout ## 'cat'ting the files together with ## 1) Putting a HEADER in front ## 2) EDITing a few of the files ## 3) appending a FOOTER ... ## Should work WHEREVER this is called from : (cd `dirname $0`/.. RHOME=`pwd`; export RHOME ) RHOME=`cd ${RHOME}; pwd` # absolute FILES="$@" #Dbg> echo "RHOME=$RHOME"; echo #Dbg> echo "FILES=$FILES"; echo ; echo; exit ## 1) ---- Header ---- echo ".ptime <- proc.time()" echo "postscript('All-Examples.ps')" echo '.pp <- par();.par.postscript <- .pp[-match(c("cin","cra","csi","din"),names(.pp))]' echo "iter <- 0; eigenval <- 1e-12" ## 2) ---- edit a few of these files: for file in $FILES do bf=`basename $file .R` if [ -n "`grep '_ Examples _' $file`" ] then echo '.Random.seed <- rep(7654,3)' else if [ "$USER" = local -o "$USER" = maechler ];then ## Remind certain people to upgrade the online help echo "'$bf' has no Examples.." >& 2 fi fi #Dbg: echo $bf >&2 if [ $bf = 'on.exit' ]; then sed -e '$s/$/par(opar)/' $file elif [ $bf = 'alias' ]; then sed -e '/^library(/s/^/##Test: /' $file elif [ $bf = 'help' ]; then sed -e '/^help(topi/s/^/##Test: /' $file elif [ $bf = 'match.arg' ]; then sed -e '/^cent.*Error/s/^/##Test: /' $file elif [ $bf = 'menu' ]; then sed -e '6,$s/^/##INTERACTIVE> /' $file elif [ $bf = 'na.fail' ]; then sed -e '/^na\.fail/s/^/##Test: /' $file elif [ $bf = 'pictex' ]; then sed -e '11,$s/^/##LaTex /' $file elif [ $bf = 'postscript' ]; then sed -e '/^postscript(/s/^/## /' $file elif [ $bf = 'Random' ]; then sed -e '$s/$/.Random.seed <- 9:7/' $file elif [ $bf = 'solve' ]; then sed -e '/error:.*singular/s/^/## /' $file elif [ $bf = 'traceback' ]; then sed -e '/^[a-z]*(/s/^/##Test: /' $file elif [ $bf = 'dataentry' ]; then sed -e '/^data/s/^/##INTERACTIVE> /' $file elif [ $bf = 'edit' ]; then sed -e '/edit(/s/^/##INTERACTIVE> /; /^vi(/s/^/##INTERACTIVE> /' $file else cat $file fi if [ -n "`grep 'par(' $file`" ] then echo 'par(.par.postscript)' fi done ## 3) ---- Footer ---- echo 'cat("Time elapsed:\t", proc.time() - .ptime,"\n")' echo "dev.off(); quit('no')"