| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/command.R |
| 3 |
\name{system3} |
| 4 |
\alias{system3} |
| 5 |
\title{A customized wrapper for \code{system2()}} |
| 6 |
\usage{ |
| 7 |
system3(command, args = character(), ...) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{command, args, ...}{Passed to \code{\link[=system2]{system2()}}. Note that \code{args} will always |
| 11 |
be quoted with \code{\link[=shQuote]{shQuote()}} before passing to \code{system2()}, so you don't need |
| 12 |
to quote it yourself.} |
| 13 |
} |
| 14 |
\value{ |
| 15 |
The value returned by \code{system2()}. |
| 16 |
} |
| 17 |
\description{ |
| 18 |
If \code{system2()} returns character output (e.g., with the argument \code{stdout = TRUE}), check if the output is encoded in UTF-8. If it is, mark it with UTF-8 |
| 19 |
explicitly. If it returns an integer, treat it as an error code and throw an |
| 20 |
error if it is non-zero. |
| 21 |
} |
| 22 |
\examples{\dontshow{if (interactive()) \{} |
| 23 |
a = c("-e", "print(intToUtf8(c(20320, 22909)))") |
| 24 |
x2 = system2("Rscript", shQuote(a), stdout = TRUE) |
| 25 |
Encoding(x2) # unknown |
| 26 |
|
| 27 |
x3 = xfun::system3("Rscript", a, stdout = TRUE) |
| 28 |
# encoding of x3 should be UTF-8 if the current locale is UTF-8 |
| 29 |
!l10n_info()[["UTF-8"]] || Encoding(x3) == "UTF-8" # should be TRUE |
| 30 |
\dontshow{\}} |
| 31 |
} |