mdlincoln / clipr

R functions for reading and writing from the system clipboard
http://matthewlincoln.net/clipr/
152 stars 24 forks source link

Can clipr_available() start a process? #45

Closed jennybc closed 5 years ago

jennybc commented 5 years ago

Since clipr_available() calls clipr_available_handler() and that tries to both read and write the clipboard, don't you think a call to clipr_available() could still create problems at CRAN, i.e. it could still tickle some process and leave it running?

Perhaps clipr_available_handler() should look more like this:

clipr_available_handler <- function(...) {
  if (!interactive()) {
    clipr_allow <- as.logical(Sys.getenv("CLIPR_ALLOW", "FALSE"))
    if (!clipr_allow) {
      return(FALSE)
    }
  }
  suppressWarnings({
    read_attempt <- try(read_clip(...), silent = TRUE)
    write_attempt <- try(write_clip(read_attempt, ...), silent = TRUE)
  })
  list(read = read_attempt, write = write_attempt)
}
jennybc commented 5 years ago

I'm not entirely sure what's going on, but my spidey sense says that it is possible this issue explains why gitignore had trouble with CRAN:

https://github.com/ropensci/gitignore/issues/7

mdlincoln commented 5 years ago

Hi @jennybc - thanks so much for your patience with my response. Life intervenes!

Yes, it makes a lot of sense to weave the CLIPR_ALLOW check more deeply throughout the package. I'll incorporate this along with the other suggestions.

mdlincoln commented 5 years ago

Closed with 17bdae67de162eeeb65419829fe6d450fac202e4