[R & Unix ..] system("test",...) gives funny results...
Prof Brian Ripley
Prof Brian Ripley <ripley@stats.ox.ac.uk>
Thu, 10 Dec 1998 16:00:49 +0000 (GMT)
> Date: Thu, 10 Dec 1998 14:57:58 +0100
> From: Martin Maechler <maechler@stat.math.ethz.ch>
> [in an attempt to provide
>
> system.test <-
> function(...) { system(paste("test", ...)) == 0 }
> and then
> file.exists <-
> function(file){sapply(file, function(f)system.test("-e", f))}
>
> (which would provide S-plus [>= 4.x] compatibility)
> ]
>
But surely that is not the way to do this (and how is it going to work on
Windows?) S-PLUS uses a system call for file.exists, presumably to
access(), even on Unix.
If you want to use test, do remember that what you get is shell-specific.
If you use
system("/usr/bin/test -e /tmp")
you have some chance of working on different shells. (Even Linux, RH5.2,
has test at /usr/bin/test!)
[still interested to hear about the potential of an R builtin 'test',
relying on GNU sh-utils].
Why not use POSIX system calls instead?
--
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._