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

reading and writing to commands with open? #4232

Closed
StefanKarpinski opened this issue Sep 9, 2013 · 5 comments
Closed

reading and writing to commands with open? #4232

StefanKarpinski opened this issue Sep 9, 2013 · 5 comments
Labels
io Involving the I/O subsystem: libuv, read, write, etc. speculative Whether the change will be implemented is speculative

Comments

@StefanKarpinski
Copy link
Member

I tried this and felt that it would be a natural and intuitive interface:

open(`pbcopy`, "w") do w
  print(w, line1)
  print(w, line2)
end

Likewise, you could do this for reading from a command via a file handle:

open(`pbcopy`, "r") do r
  line1 = readline(r)
  line2 = readline(r)
end

Thoughts on this as an API? I wonder if we could fit reading and writing from a process simultaneously into something like this too.

@johnmyleswhite
Copy link
Member

I'd be happy with this.

@StefanKarpinski
Copy link
Member Author

I'm a bit concerned that this may be a pun on the meaning of open, but it's still more convenient than what we have now for doing this (readsto and writesto, while they work, are kind of low level).

@Keno
Copy link
Member

Keno commented Sep 10, 2013

Considering UNIX has popen this is probably not that far off.

@kmsquire
Copy link
Member

I like it. Are there technical issues in making it bi-directional?

Kevin

On Tue, Sep 10, 2013 at 9:09 AM, Keno Fischer [email protected]:

Considering UNIX has popen this is probably not that far off.


Reply to this email directly or view it on GitHubhttps://github.com//issues/4232#issuecomment-24173312
.

@JeffBezanson
Copy link
Member

Implemented by #6948

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
io Involving the I/O subsystem: libuv, read, write, etc. speculative Whether the change will be implemented is speculative
Projects
None yet
Development

No branches or pull requests

5 participants