This question was motivated by Rmarkdown not outputting results of system command to html file. For some reason, the output of system() in R (or system2()
You could add a function knitr::system that masks base::system. Users could work with it like it was system::base, but the output can be captured by capture.output:
system <- function(...) {
stopifnot(!any(names(list(...)) %in% "intern"))
result <- base::system(..., intern = TRUE)
print(result)
}
I admit, that this is somewhat hacky, and to be honest, I'm not sure about possible side effects. But I think it could be worth a try.