Skip to content

Commit 82bcfc0

Browse files
committed
Simplified path quoting function
1 parent 2659720 commit 82bcfc0

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

R/RcppLdpath.R

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,11 @@ Rcpp.system.file <- function(...){
2121
}
2222

2323
## quote path if non-standard characters are used
24-
Rcpp.quoteNonStandard <- function(path, quoteAll = .Platform$OS.type!="unix") {
25-
quoted <- shQuote(path)
26-
if (quoteAll) {
27-
quoted
28-
} else {
29-
# Select paths in which all characters do not need quoting
30-
sel <- grepl("^[[:alnum:]/._~+@%-]*$", path)
31-
# Quote remaining paths
32-
ifelse(sel, path, quoted)
33-
}
24+
Rcpp.quoteNonStandard <- function(path) {
25+
## On unix, check if path has only characters that do not need quoting
26+
noquote <- .Platform$OS.type == "unix" && grepl("^[[:alnum:]/._~+@%-]*$", path)
27+
## If no quoting needed return unchanged else quote input
28+
if (noquote) path else shQuote(path)
3429
}
3530

3631
## Use R's internal knowledge of path settings to find the lib/ directory

0 commit comments

Comments
 (0)