Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set directory for process #63

Closed
wch opened this issue Jul 19, 2017 · 1 comment
Closed

Set directory for process #63

wch opened this issue Jul 19, 2017 · 1 comment

Comments

@wch
Copy link
Member

wch commented Jul 19, 2017

Right now, if you want to start a process in a directory other than R's current dir, you need to call setwd() before starting the process, and then call it again afterward. And for extra safety, you would want to call setwd() in an on.exit, in case there's an error.

  old_dir <- setwd(new_dir)
  # In case we have an error in process$new(), use on.exit
  on.exit(setwd(old_dir))
  p <- process$new("ls", stdout = "|")$wait()
  setwd(old_dir)

It would be nice if there were an option to process$new that let you set the working directory.

@gaborcsardi
Copy link
Member

gaborcsardi commented Jul 19, 2017

You can also use withr::with_dir. But yeah, we can have an option.

@gaborcsardi gaborcsardi modified the milestone: Version 3.0.0 Oct 19, 2017
gaborcsardi added a commit that referenced this issue May 13, 2018
gaborcsardi added a commit that referenced this issue May 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants