Skip to content

Instantly share code, notes, and snippets.

@NoahMarconi
Last active April 18, 2016 02:56
Show Gist options
  • Save NoahMarconi/f310d4efccf61600c7df041a7cf5e66a to your computer and use it in GitHub Desktop.
Save NoahMarconi/f310d4efccf61600c7df041a7cf5e66a to your computer and use it in GitHub Desktop.
run-r handler for Hook.io R runtime.
#!/usr/bin/env r
#
# run-r handler for Hook.io R runtime.
#
# Copyright (C) 2016 Noah Marconi
#
# Released under MIT
doc <- "Usage: run-r [-c CODE] [-e ENVIRONMENT] [-s SERVICE]
-c CODE R code to evaluate.
-e ENVIRONMENT ?
-s SERVICE ?"
if (is.null(argv) | length(argv)<1) {
cat(doc, "\n")
q()
}
arg_flags_idx <- grep("^-", argv)
arg_vals_idx <- arg_flags_idx+1
opts <- as.list(argv[arg_vals_idx])
names(opts) <- argv[arg_flags_idx]
RAppArmor::eval.secure(parse(text=opts$`-c`))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment