The R Project SVN R

Rev

Rev 61425 | Rev 67599 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42479 ripley 1
% File src/library/base/man/Sys.which.Rd
2
% Part of the R package, http://www.R-project.org
59522 ripley 3
% Copyright 2007-12 R Core Team
42479 ripley 4
% Distributed under GPL 2 or later
5
 
6
\name{Sys.which}
56186 murdoch 7
\alias{Sys.which}
52810 ripley 8
\title{Find Full Paths to Executables}
42479 ripley 9
\description{
59542 ripley 10
  This is an interface to the system command \code{which}, or to an
11
  emulation on Windows.
42479 ripley 12
}
13
\usage{
14
Sys.which(names)
15
}
16
\arguments{
59542 ripley 17
  \item{names}{Character vector of names or paths of possible executables.}
42479 ripley 18
}
19
\details{
59522 ripley 20
  The system command \command{which} reports on the full path names of
21
  an executable (including an executable script) as would be executed by
22
  a shell, accepting either absolute paths or looking on the path.
42479 ripley 23
 
50567 ripley 24
  On Windows an \sQuote{executable} is a file with extension
25
  \file{.exe}, \file{.com}, \file{.cmd} or \file{.bat}.  Such files need
52810 ripley 26
  not actually be executable, but they are what \code{\link{system}}
50567 ripley 27
  tries.
61433 ripley 28
 
53037 ripley 29
  On a Unix-alike the full path to \code{which} (usually
59522 ripley 30
  \file{/usr/bin/which}) is found when \R is installed.
42479 ripley 31
}
32
\value{
33
  A character vector of the same length as \code{names}, named by
34
  \code{names}.  The elements are either the full path to the
52810 ripley 35
  executable  or some indication that no executable of that name was
51774 ripley 36
  found.  Typically the indication is \code{""}, but this does depend on
61425 ripley 37
  the OS (and the known exceptions are changed to \code{""}).  Missing
38
  values in \code{names} have missing return values (as from \R 3.0.0).
42480 ripley 39
 
59542 ripley 40
  On Windows the paths will be short paths (8+3 components, no spaces)
41
  with \code{\\} as the path delimiter.
42479 ripley 42
}
59522 ripley 43
\note{
44
  Except on Windows this calls the system command \command{which}: since
45
  that is not part of e.g. the POSIX standards, exactly what it does is
46
  OS-dependent.  It will usually do tilde-expansion and it may make use
47
  of \command{csh} aliases.
59542 ripley 48
 
61282 ripley 49
  In \R 2.x.y, arguments containing spaces or other metacharacters
50
  needed to be escaped as they would be for a shell: for example Windows
51
  paths containing spaces needed to be enclosed in double quotes.
59522 ripley 52
}
42479 ripley 53
\examples{
42480 ripley 54
## the first two are likely to exist everywhere
55
## texi2dvi exists on most Unix-alikes and under MiKTeX
56
Sys.which(c("ftp", "ping", "texi2dvi", "this-does-not-exist"))
42479 ripley 57
}
58
\keyword{ utilities }