[Rd] source() chdir does not work (PR#7940)

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Wed Jun 15 12:51:45 CEST 2005


This is already fixed:

     o	source(file, chdir = TRUE) was not checking that 'file' was a
 	filepath (rather than a URL).  For 2.1.0 only, it did not work
 	even if 'file' was a filepath.

>From the R FAQ:

    Before you actually submit a bug report, you should check whether the 
bug has already been reported and/or fixed.  First, try the "Search 
Existing Reports" facility in the Bug Tracking page at 
`http://bugs.R-project.org/'.  Second, consult 
`https://svn.R-project.org/R/trunk/NEWS', which records changes that will 
appear in the _next_ release of R, including some bug fixes that do not 
appear in Bug Tracking.  (Windows users should additionally consult 
`https://svn.R-project.org/R/trunk/src/gnuwin32/CHANGES'.)  Third, if 
possible try the current r-patched or r-devel version of R.  If a bug has 
already been reported or fixed,
please do not submit further bug reports on it.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

On Wed, 15 Jun 2005 agalakhov at ifmlrs.uran.ru wrote:

> Full_Name: Alex Galakhov
> Version: 2.1.0
> OS: Linux (Debian)
> Submission from: (NULL) (195.19.131.68)
>
>
> After software upgrade source() does not work properly anymore. It completely
> ignores the chdir= parameter. This is because is.character(file) is always false
> after the assignment file<-file(file).
>
> The fix is (written by hand in diff-like syntax, hopefully, you'll understand
> it):
>
> source<- function (blablabla) {
> +filename <- file
> ...blablabla
> -if (chdir && is.character (file) && ... dirname(file) ...) {
> +if (chdir && is.character (filename) && ... dirname(filename) ...) {
> +close(file) # since we can have only one on.exit(), we close file here
> ...blablabla
> on.exit(setwd(owd));
> }


-- 
Brian D. Ripley,                  ripley at 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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list