Skip to content

Commit

Permalink
Simplified path quoting function
Browse files Browse the repository at this point in the history
  • Loading branch information
llaniewski committed Jan 24, 2023
1 parent 2659720 commit 82bcfc0
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions R/RcppLdpath.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,11 @@ Rcpp.system.file <- function(...){
}

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

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

0 comments on commit 82bcfc0

Please sign in to comment.