You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The use case for either having a "command splitter" or being able to bypass "command splitting" is when using an ephemeral container to run a single command line invocation and capture the output.
Are there any recommendation when it comes to using stevedore to "shell out" to run a command (which may involve pipes) and capture the output?
Below is an illustration/attempt using "jq" which is available in the "docker.io/endeveit/docker-jq" image. It looks like stevedore allows running commands that does not contain quotation marks.
stevedore_runc<-function(container_slug, command, use_split=FALSE, rm=TRUE) {
stopifnot(stevedore::docker_available())
docker<-stevedore::docker_client()
# capture output from commandoutput<- textConnection(tempfile(), "w")
on.exit(close(output))
# any command needs to be splitsplit_cmd<-function(x)
unlist(strsplit(x, "\\s+"))
cli<-commandif(use_split) cli<- split_cmd(command)
message("CLI command is:", cli)
str(cli)
# stream output from command and return itinvisible(docker$container$run(
container_slug,
cmd=cli,
rm=TRUE,
stream=output)
)
# a leading "O> " gets inserted, strip it outres<- textConnectionValue(output)
gsub("^O> ", "", res)
}
# works ok if no quotes
stevedore_runc("docker.io/endeveit/docker-jq",
command="jq --help", use_split=TRUE)
stevedore_runc("docker.io/endeveit/docker-jq",
command= I("jq --help"), use_split=FALSE)
# quotes are causing problems and cannot easily bypass the "command splitter"?
stevedore_runc("docker.io/endeveit/docker-jq",
command= I(c('echo "hello"')), use_split=FALSE)
stevedore_runc("docker.io/endeveit/docker-jq",
command= I(c("echo 'hello'")), use_split=FALSE)
stevedore_runc("docker.io/endeveit/docker-jq",
command= I('jq --version # "no, does not seem so"'), use_split=FALSE)
The text was updated successfully, but these errors were encountered:
The use case for either having a "command splitter" or being able to bypass "command splitting" is when using an ephemeral container to run a single command line invocation and capture the output.
Are there any recommendation when it comes to using stevedore to "shell out" to run a command (which may involve pipes) and capture the output?
Below is an illustration/attempt using "jq" which is available in the "docker.io/endeveit/docker-jq" image. It looks like stevedore allows running commands that does not contain quotation marks.
The text was updated successfully, but these errors were encountered: