{"action":"created","issue":{"url":"https://api.github.com/repos/atom/atom/issues/11184","repository_url":"https://api.github.com/repos/atom/atom","labels_url":"https://api.github.com/repos/atom/atom/issues/11184/labels{/name}","comments_url":"https://api.github.com/repos/atom/atom/issues/11184/comments","events_url":"https://api.github.com/repos/atom/atom/issues/11184/events","html_url":"https://github.com/atom/atom/pull/11184","id":141616597,"number":11184,"title":"cli: Open stdin as a file when present","user":{"login":"mkhl","id":505,"avatar_url":"https://avatars.githubusercontent.com/u/505?v=3","gravatar_id":"","url":"https://api.github.com/users/mkhl","html_url":"https://github.com/mkhl","followers_url":"https://api.github.com/users/mkhl/followers","following_url":"https://api.github.com/users/mkhl/following{/other_user}","gists_url":"https://api.github.com/users/mkhl/gists{/gist_id}","starred_url":"https://api.github.com/users/mkhl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkhl/subscriptions","organizations_url":"https://api.github.com/users/mkhl/orgs","repos_url":"https://api.github.com/users/mkhl/repos","events_url":"https://api.github.com/users/mkhl/events{/privacy}","received_events_url":"https://api.github.com/users/mkhl/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/atom/atom/labels/needs-review","name":"needs-review","color":"bfe5bf"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-03-17T15:28:12Z","updated_at":"2016-04-26T20:44:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/atom/atom/pulls/11184","html_url":"https://github.com/atom/atom/pull/11184","diff_url":"https://github.com/atom/atom/pull/11184.diff","patch_url":"https://github.com/atom/atom/pull/11184.patch"},"body":"The [atom cli discards its input from stdin][1] when other editors would open a new document containing that text.\r\n\r\nThis change writes input from stdin to a new temporary file and inserts that file as the first argument to the atom executable.\r\nIt only does that when stdin is not at tty, i.e. running `git diff | atom` creates and opens a temporary file but running `atom some/file` does not.\r\n\r\nCloses https://github.com/atom/atom/issues/1729\r\n\r\n## Caveats\r\n\r\n* [ ] Errors from `mktemp` are not handled.\r\n* [ ] The call to `mktemp` appears before ensuring that `TMPDIR` is set on line 105.\r\n* [ ] `mktemp` is called without arguments, resulting in a filename like `tmp.XXXXXXXX`.  \r\nA filename prefix like `atom-stdin` would be nicer but the mktemp commands on [Linux][2] and [OS X][3] are sufficiently different to make this more involved. (A call like `mktemp -t atom-stdin` would work on OS X but wouldn't include a random suffix on Linux, if I understand the man page correctly.)\r\n[1]: https://discuss.atom.io/t/it-would-be-nice-to-be-able-to-pipe-standard-out-to-atom-and-have-it-open-in-an-unsaved-document/4781\r\n[2]: http://www.unix.com/man-page/linux/1/mktemp/\r\n[3]: http://www.unix.com/man-page/osx/1/mktemp/"},"comment":{"url":"https://api.github.com/repos/atom/atom/issues/comments/214880049","html_url":"https://github.com/atom/atom/pull/11184#issuecomment-214880049","issue_url":"https://api.github.com/repos/atom/atom/issues/11184","id":214880049,"user":{"login":"50Wliu","id":2766036,"avatar_url":"https://avatars.githubusercontent.com/u/2766036?v=3","gravatar_id":"","url":"https://api.github.com/users/50Wliu","html_url":"https://github.com/50Wliu","followers_url":"https://api.github.com/users/50Wliu/followers","following_url":"https://api.github.com/users/50Wliu/following{/other_user}","gists_url":"https://api.github.com/users/50Wliu/gists{/gist_id}","starred_url":"https://api.github.com/users/50Wliu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/50Wliu/subscriptions","organizations_url":"https://api.github.com/users/50Wliu/orgs","repos_url":"https://api.github.com/users/50Wliu/repos","events_url":"https://api.github.com/users/50Wliu/events{/privacy}","received_events_url":"https://api.github.com/users/50Wliu/received_events","type":"User","site_admin":false},"created_at":"2016-04-26T20:44:08Z","updated_at":"2016-04-26T20:44:08Z","body":"Tested on Ubuntu and everything seems to work fine (other than the tmp folder opening as a project root, but that's a different issue).\r\n\r\nTried:\r\n`git log | atom`\r\n`git log | atom --foreground`\r\n`ps aux | grep \"atom\" | atom` (yes I know there's `pgrep`, just wanted to make sure multiple pipes worked)\r\n`ps aux | grep \"atom\" | atom package.json` (this opens up both files but focuses `package.json`)\r\n`ps aux | grep \"atom\" | atom --foreground --safe --dev package.json`"}}