R Under development (unstable) (2024-12-17 r87446 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > message("*** utils,cluster ...") *** utils,cluster ... > > shQuote <- parallelly:::shQuote > > check_types <- function(cmd = "foo bar", os = NULL) { + if (is.null(os)) { + info <- "" + } else { + environment(shQuote)[[".Platform"]] <- list(OS.type = os) + on.exit(rm(list = ".Platform", envir = environment(shQuote))) + info <- sprintf(" with os = '%s'", os) + } + + for (type in list("sh", "cmd", "none", NULL, NA)) { + type_str <- if (is.null(type)) "NULL" else sprintf('"%s"', type) + message(sprintf("- sQuote(... type = %s)%s", type_str, info)) + if (is.null(type)) { + value <- shQuote(cmd, type = type) + if (is.null(os) || os == .Platform$OS.type) { + truth <- base::shQuote(cmd) + } else if (os == "unix") { + truth <- base::shQuote(cmd, type = "sh") + } else if (os == "windows") { + truth <- base::shQuote(cmd, type = "cmd") + } + } else if (is.na(type)) { + value <- shQuote(cmd) + if (is.null(os) || os == .Platform$OS.type) { + truth <- base::shQuote(cmd) + } else if (os == "unix") { + truth <- base::shQuote(cmd, type = "sh") + } else if (os == "windows") { + truth <- base::shQuote(cmd, type = "cmd") + } + } else if (type == "none") { + value <- shQuote(cmd, type = type) + truth <- cmd + } else { + value <- shQuote(cmd, type = type) + truth <- base::shQuote(cmd, type = type) + } + str(list(value = value, truth = truth)) + stopifnot(value == truth) + } + } > > > message("- sQuote()") - sQuote() > > cmd <- "foo bar" > stopifnot(shQuote(cmd) == base::shQuote(cmd)) > > > for (os in list(NULL, "unix", "windows")) { + check_types(cmd = cmd, os = os) + } - sQuote(... type = "sh") List of 2 $ value: chr "'foo bar'" $ truth: chr "'foo bar'" - sQuote(... type = "cmd") List of 2 $ value: chr "\"foo bar\"" $ truth: chr "\"foo bar\"" - sQuote(... type = "none") List of 2 $ value: chr "foo bar" $ truth: chr "foo bar" - sQuote(... type = NULL) List of 2 $ value: chr "\"foo bar\"" $ truth: chr "\"foo bar\"" - sQuote(... type = "NA") List of 2 $ value: chr "\"foo bar\"" $ truth: chr "\"foo bar\"" - sQuote(... type = "sh") with os = 'unix' List of 2 $ value: chr "'foo bar'" $ truth: chr "'foo bar'" - sQuote(... type = "cmd") with os = 'unix' List of 2 $ value: chr "\"foo bar\"" $ truth: chr "\"foo bar\"" - sQuote(... type = "none") with os = 'unix' List of 2 $ value: chr "foo bar" $ truth: chr "foo bar" - sQuote(... type = NULL) with os = 'unix' List of 2 $ value: chr "'foo bar'" $ truth: chr "'foo bar'" - sQuote(... type = "NA") with os = 'unix' List of 2 $ value: chr "'foo bar'" $ truth: chr "'foo bar'" - sQuote(... type = "sh") with os = 'windows' List of 2 $ value: chr "'foo bar'" $ truth: chr "'foo bar'" - sQuote(... type = "cmd") with os = 'windows' List of 2 $ value: chr "\"foo bar\"" $ truth: chr "\"foo bar\"" - sQuote(... type = "none") with os = 'windows' List of 2 $ value: chr "foo bar" $ truth: chr "foo bar" - sQuote(... type = NULL) with os = 'windows' List of 2 $ value: chr "\"foo bar\"" $ truth: chr "\"foo bar\"" - sQuote(... type = "NA") with os = 'windows' List of 2 $ value: chr "\"foo bar\"" $ truth: chr "\"foo bar\"" > > > message("*** utils,cluster ... DONE") *** utils,cluster ... DONE > > proc.time() user system elapsed 0.26 0.15 0.36