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

agalakhov@ifmlrs.uran.ru agalakhov at ifmlrs.uran.ru
Wed Jun 15 12:37:00 CEST 2005

Full_Name: Alex Galakhov
Version: 2.1.0
OS: Linux (Debian)
Submission from: (NULL) (

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

 source<- function (blablabla) {
+filename <- file
-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

More information about the R-devel mailing list