Kutip string yang akan diteruskan ke shell sistem operasi.
shQuote(string, type = c("sh", "csh", "cmd", "cmd2"))
| Parameter | Deskripsi |
|---|---|
string |
a character vector, usually of length one. |
type |
character: the type of shell quoting. Partial matching is supported. "cmd" and "cmd2" refer to the Windows shell. "cmd" is the default under Windows. |
# NOT RUN {
test <- "abc$def`gh`i\\j"
cat(shQuote(test), "\n")
# }
# NOT RUN {
system(paste("echo", shQuote(test)))
# }
# NOT RUN {
test <- "don't do it!"
cat(shQuote(test), "\n")
tryit <- paste("use the", sQuote("-c"), "switch\nlike this")
cat(shQuote(tryit), "\n")
# }
# NOT RUN {
system(paste("echo", shQuote(tryit)))
# }
# NOT RUN {
cat(shQuote(tryit, type = "csh"), "\n")
## Windows-only example, assuming cmd.exe:
perlcmd <- 'print "Hello World\\n";'
# }
# NOT RUN {
shell(shQuote(paste("perl -e",
shQuote(perlcmd, type = "cmd")),
type = "cmd2"))
# }