prevent all bash code chunks from being evaluated when knitting

Hi all,

Is there any option to prevent all {bash} code chunks from being evaluated?

I know I can set it for each chunk with eval=FALSE, but I was hoping there would be a way to do this for all chunks at once.



1 Like

You can specify an option hook that sets eval to FALSE if engine is bash. In the example Rmd file below, only the code in the R chunk will be evaluated:

title: "Untitled"
output: html_document

```{r setup, include=FALSE}
knitr::opts_hooks$set(eval = function(options) {
  if (options$engine == "bash") {
    options$eval <- FALSE


echo "run"

You can read more about option hooks in the chapter Option hooks from the R Markdown Cookbook.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Great, Thanks a lot for your help

1 Like