From ripley@stats.ox.ac.uk  Wed Jun 19 18:30:27 2002
From: ripley@stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Wed, 19 Jun 2002 18:30:27 +0100 (BST)
Subject: overzealous help-links.sh script! (PR#1682)
In-Reply-To: <200206171311.PAA15557@pubhealth.ku.dk>
Message-ID: <Pine.LNX.4.31.0206191820320.11375-100000@gannet.stats>

Not a bug.  .R is a `hidden' private directory for R's own use.
Have you been trespassing:  `including stuff the user might have
installed' suggests you have?

On Mon, 17 Jun 2002 rjvbertin@hotmail.com wrote:

> Starting html help in the current version of R has a very annoying
> side-effect. It indiscriminantly removes $HOME/.R, and replaces it with a
> virgin copy. I discovered that when all of a sudden I got complaints about
> my startup "library" not being found.
> Below is a modified version of the script that doesn't do this. It is not
> perfect yet (it shouldn't try to recreate links that already exists; there

Why: the targets of the links may well have changed?  Remember that
R_HOME can change from invocation to invocation, and if there are
different R versions (even on different platforms) keeping anything is
completely inappropriate.  You can't even delete just what you want to
replace, as .R might have been created by a later R version and put other
things in there.

> must be a glitch in the multi-test if lines) but it is safer than the
> previous version!

Not so.  Have you read the section on BUGS in the FAQ recently?

>
> RenE Bertin
>
>
> #! /bin/sh
>
> # 20020615 RJVB : I modified this script such that it will not at each
> invocation throw away the ~/.R directory
> # with all that it contains (including stuff the user might have
> installed!!)
> # Instead, it will create what doesn't exist, and warn whenever an error
> occurs (= a dir can't be made because a file
> # with the same name exists.
> # For the links, I try to be clever, and put in only those that aren't there
> yet, but this doesn't yet function
> # correctly with the single-line-2-test expression. Therefore, all output
> from ln is thrown away :)
>
> USER_R_HOME="${HOME}/.R"
> PKGLIST="${USER_R_HOME}/doc/html/packages.html"
> SEARCHINDEX="${USER_R_HOME}/doc/html/search/index.txt"
> # RJVB: don't do this!!
> # rm -rf ${USER_R_HOME}
>
> dirs="${USER_R_HOME} ${USER_R_HOME}/doc ${USER_R_HOME}/doc/html
> ${USER_R_HOME}/doc/html/search ${USER_R_HOME}/library"
> for d in ${dirs}; do
> # RJVB
>     if [ ! -e ${d} ] ;then
> 	    mkdir -p ${d}
> 	elif [ ! -d ${d} ] ;then
> 		echo "Warning: ${d} already exists but is not a directory!"
> 	fi
> done
>
> for f in AUTHORS COPYING THANKS; do
> # RJVB
>   if [ -f ${R_HOME}/${f} -a ! -e ${USER_R_HOME}/${f} ] ;then
>     ln -s ${R_HOME}/${f} ${USER_R_HOME}/${f}
>   fi
> done
>
> # RJVB
> if [ -d ${R_HOME}/doc/manual -a ! -e ${USER_R_HOME}/doc/manual ] ;then
>   ln -s ${R_HOME}/doc/manual ${USER_R_HOME}/doc/manual
> fi
>
> for f in ${R_HOME}/doc/html/*; do
> # RJVB
>     if [ -f $f -a ! -e ${USER_R_HOME}/doc/html/${f} ] ;then
> 	ln -s ${f} ${USER_R_HOME}/doc/html 1>/dev/null 2>1
>     fi
> done
>
> for f in ${R_HOME}/doc/html/search/*; do
> # RJVB
>     if [ -f $f -a ! -e ${USER_R_HOME}/doc/html/search/${f} ] ;then
> 	ln -s ${f} ${USER_R_HOME}/doc/html/search 1>/dev/null 2>1
>     fi
> done
>
> rm -f ${PKGLIST}
> rm -f ${SEARCHINDEX}
> cp ${R_HOME}/doc/html/packages-head.html ${PKGLIST}
>
> get_unique () {
>   if test -r ${1}; then
>     x="1"
>     while test -r ${1}.${x}; do
>       x=`echo "$x+1" | bc`
>     done
>     echo ${1}.${x}
>   else
>     echo $1
>   fi
> }
>
>
> for lib in $*; do
>     echo "<p><h3>Packages in ${lib}</h3>" >> ${PKGLIST}
>     echo "<p><table width=\"100%\">" >> ${PKGLIST}
>     if test -d ${lib}; then
>       for pkg in `ls -d ${lib}/* | sed '/CVS$/d; /profile$/d'`; do
> 	if test -d ${pkg}; then
> 	    pkgname=`basename ${pkg}`
> 	    target=`get_unique ${USER_R_HOME}/library/${pkgname}`
> 	    targetname=`basename ${target}`
> 	    ln -s ${pkg} ${target}
> 	    if test -r ${pkg}/TITLE; then
> 		pkgtitle=`cat ${pkg}/TITLE | sed "s/^${pkgname}//"`
> 	    else
> 		pkgtitle=""
> 	    fi
> 	    echo "<tr align=\"left\" valign=\"top\">
> 		    <td width=\"25%\"><a
> href=\"../../library/${targetname}/html/00Index.html\">
> 		    ${pkgname}</a><td>${pkgtitle}</td></tr>" \
> 		>> ${PKGLIST}
>
> 	    cat ${pkg}/CONTENTS | \
> 	      sed "s/\/library\/${pkgname}\//\/library\/${targetname}\//;" \
> 	      >> ${SEARCHINDEX}
>
>
> 	fi
>       done
>     fi
>     echo "</table>" >> ${PKGLIST}
>     echo "" >> ${PKGLIST}
> done
>
> echo "</body></html>" >> ${PKGLIST}
> ln -s ${R_HOME}/doc/html/R.css ${USER_R_HOME}/library 1>/dev/null 2>1
>
> ### Local Variables: ***
> ### mode: sh ***
> ### sh-indentation: 2 ***
> ### End: ***
>
>
> RenE J.V. Bertin
> College de France/LPPA
> 11, place Marcelin Berthelot
> 75005 Paris, France
>
> _________________________________________________________________
>
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


overzealous help-links.sh script! (PR#1682)
ripley@stats.ox.ac.uk