Commit dcdc91ad authored by Holger Brandl's avatar Holger Brandl

added shebang filter

parent 89115af7
...@@ -38,6 +38,12 @@ if(!file.exists(r_script)){ ...@@ -38,6 +38,12 @@ if(!file.exists(r_script)){
## postfix a default empty yaml header ## postfix a default empty yaml header
tmpScript <- tempfile(fileext=".R") tmpScript <- tempfile(fileext=".R")
## remove sheband and comment-only lines from source document
#file.copy(r_script, tmpScript)
system(paste("cat ", r_script," | grep -Ev '^#+$' | grep -Fv '#!/usr/bin/env Rscript' >", tmpScript))
## add yaml header (will be ignored if already present
metadata <- paste('\n', metadata <- paste('\n',
'#\'---\n', '#\'---\n',
'#\'title: ""\n', '#\'title: ""\n',
...@@ -45,7 +51,6 @@ metadata <- paste('\n', ...@@ -45,7 +51,6 @@ metadata <- paste('\n',
'#\'date: ""\n', '#\'date: ""\n',
'#\'---\n' '#\'---\n'
, sep = "") , sep = "")
file.copy(r_script, tmpScript)
cat(metadata, file = tmpScript, append = TRUE) cat(metadata, file = tmpScript, append = TRUE)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment