{"action":"opened","number":4515,"pull_request":{"url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/pulls/4515","id":48013318,"html_url":"https://github.com/robbyrussell/oh-my-zsh/pull/4515","diff_url":"https://github.com/robbyrussell/oh-my-zsh/pull/4515.diff","patch_url":"https://github.com/robbyrussell/oh-my-zsh/pull/4515.patch","issue_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/issues/4515","number":4515,"state":"open","locked":false,"title":"Make install script safer","user":{"login":"brianloveswords","id":166258,"avatar_url":"https://avatars.githubusercontent.com/u/166258?v=3","gravatar_id":"","url":"https://api.github.com/users/brianloveswords","html_url":"https://github.com/brianloveswords","followers_url":"https://api.github.com/users/brianloveswords/followers","following_url":"https://api.github.com/users/brianloveswords/following{/other_user}","gists_url":"https://api.github.com/users/brianloveswords/gists{/gist_id}","starred_url":"https://api.github.com/users/brianloveswords/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianloveswords/subscriptions","organizations_url":"https://api.github.com/users/brianloveswords/orgs","repos_url":"https://api.github.com/users/brianloveswords/repos","events_url":"https://api.github.com/users/brianloveswords/events{/privacy}","received_events_url":"https://api.github.com/users/brianloveswords/received_events","type":"User","site_admin":false},"body":"This changeset wraps all of the commands in tools/install.sh in a\r\nfunction and then calls that function as the last line of the\r\nscript.\r\n\r\nThe current install instructions ask the user to download the install\r\nscript using `curl` and pass the result to `sh`. This is totally\r\nfine (as long as both the instructions and the script itself are served\r\nusing HTTPS), but the script should be written in a way such that it\r\ndoesn't start trying to actually *do* anything until the very last line.\r\n\r\nThe reason is due to the way `curl` work: if the socket drops before the\r\nrequest is complete (server abruptly hangs up, client's internet flakes\r\nout, etc.), `curl` will return the partial data that it received. Here\r\nis an example of that:\r\n\r\n![partial file execution](https://cldup.com/qU_Mnh2GmT.png)\r\n\r\nA way this might cause issues for tools/install.sh is if the connection drops\r\nafter cloning but before the repository (L53-56). The .zshrc\r\nconfiguration will not be copied and the shell will not be changed, but\r\nif the user tries to run the install script again it will claim\r\noh-my-zsh is already installed (L31-39).\r\n\r\nWhile this is not a particularly dangerous error condition (the user can\r\njust delete .oh-my-zsh and re-run), it can certainly be confusing for\r\nnew users. This also helps future-proof the script for a time when it\r\nmight need to use a \"dangerous\" command, e.g. `rm`, and we want to make\r\nsure it happens in the most transactional way possible.","created_at":"2015-10-18T17:44:14Z","updated_at":"2015-10-18T17:44:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/pulls/4515/commits","review_comments_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/pulls/4515/comments","review_comment_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/issues/4515/comments","statuses_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/statuses/e8946ce8111c21f75c4787756573b8d24866d73e","head":{"label":"brianloveswords:safer-install-script","ref":"safer-install-script","sha":"e8946ce8111c21f75c4787756573b8d24866d73e","user":{"login":"brianloveswords","id":166258,"avatar_url":"https://avatars.githubusercontent.com/u/166258?v=3","gravatar_id":"","url":"https://api.github.com/users/brianloveswords","html_url":"https://github.com/brianloveswords","followers_url":"https://api.github.com/users/brianloveswords/followers","following_url":"https://api.github.com/users/brianloveswords/following{/other_user}","gists_url":"https://api.github.com/users/brianloveswords/gists{/gist_id}","starred_url":"https://api.github.com/users/brianloveswords/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianloveswords/subscriptions","organizations_url":"https://api.github.com/users/brianloveswords/orgs","repos_url":"https://api.github.com/users/brianloveswords/repos","events_url":"https://api.github.com/users/brianloveswords/events{/privacy}","received_events_url":"https://api.github.com/users/brianloveswords/received_events","type":"User","site_admin":false},"repo":{"id":1256153,"name":"oh-my-zsh","full_name":"brianloveswords/oh-my-zsh","owner":{"login":"brianloveswords","id":166258,"avatar_url":"https://avatars.githubusercontent.com/u/166258?v=3","gravatar_id":"","url":"https://api.github.com/users/brianloveswords","html_url":"https://github.com/brianloveswords","followers_url":"https://api.github.com/users/brianloveswords/followers","following_url":"https://api.github.com/users/brianloveswords/following{/other_user}","gists_url":"https://api.github.com/users/brianloveswords/gists{/gist_id}","starred_url":"https://api.github.com/users/brianloveswords/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianloveswords/subscriptions","organizations_url":"https://api.github.com/users/brianloveswords/orgs","repos_url":"https://api.github.com/users/brianloveswords/repos","events_url":"https://api.github.com/users/brianloveswords/events{/privacy}","received_events_url":"https://api.github.com/users/brianloveswords/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brianloveswords/oh-my-zsh","description":"A community-driven framework for managing your zsh configuration. Includes optional plugins for various tools (rails, git, OSX, brew,...), over 40 terminal themes, and an auto-updating tool so that you can keep up with the latest improvements from the community.","fork":true,"url":"https://api.github.com/repos/brianloveswords/oh-my-zsh","forks_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/forks","keys_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/teams","hooks_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/hooks","issue_events_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/issues/events{/number}","events_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/events","assignees_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/assignees{/user}","branches_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/branches{/branch}","tags_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/tags","blobs_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/git/refs{/sha}","trees_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/statuses/{sha}","languages_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/languages","stargazers_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/stargazers","contributors_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/contributors","subscribers_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/subscribers","subscription_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/subscription","commits_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/commits{/sha}","git_commits_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/git/commits{/sha}","comments_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/comments{/number}","issue_comment_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/issues/comments{/number}","contents_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/contents/{+path}","compare_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/merges","archive_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/downloads","issues_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/issues{/number}","pulls_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/pulls{/number}","milestones_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/milestones{/number}","notifications_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/labels{/name}","releases_url":"https://api.github.com/repos/brianloveswords/oh-my-zsh/releases{/id}","created_at":"2011-01-14T22:28:18Z","updated_at":"2015-10-18T16:33:09Z","pushed_at":"2015-10-18T17:43:22Z","git_url":"git://github.com/brianloveswords/oh-my-zsh.git","ssh_url":"git@github.com:brianloveswords/oh-my-zsh.git","clone_url":"https://github.com/brianloveswords/oh-my-zsh.git","svn_url":"https://github.com/brianloveswords/oh-my-zsh","homepage":"","size":2291,"stargazers_count":1,"watchers_count":1,"language":"Shell","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"robbyrussell:master","ref":"master","sha":"aa15ebad3e9c86fbd8dd5f01803066f82ece9593","user":{"login":"robbyrussell","id":257,"avatar_url":"https://avatars.githubusercontent.com/u/257?v=3","gravatar_id":"","url":"https://api.github.com/users/robbyrussell","html_url":"https://github.com/robbyrussell","followers_url":"https://api.github.com/users/robbyrussell/followers","following_url":"https://api.github.com/users/robbyrussell/following{/other_user}","gists_url":"https://api.github.com/users/robbyrussell/gists{/gist_id}","starred_url":"https://api.github.com/users/robbyrussell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robbyrussell/subscriptions","organizations_url":"https://api.github.com/users/robbyrussell/orgs","repos_url":"https://api.github.com/users/robbyrussell/repos","events_url":"https://api.github.com/users/robbyrussell/events{/privacy}","received_events_url":"https://api.github.com/users/robbyrussell/received_events","type":"User","site_admin":false},"repo":{"id":291137,"name":"oh-my-zsh","full_name":"robbyrussell/oh-my-zsh","owner":{"login":"robbyrussell","id":257,"avatar_url":"https://avatars.githubusercontent.com/u/257?v=3","gravatar_id":"","url":"https://api.github.com/users/robbyrussell","html_url":"https://github.com/robbyrussell","followers_url":"https://api.github.com/users/robbyrussell/followers","following_url":"https://api.github.com/users/robbyrussell/following{/other_user}","gists_url":"https://api.github.com/users/robbyrussell/gists{/gist_id}","starred_url":"https://api.github.com/users/robbyrussell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robbyrussell/subscriptions","organizations_url":"https://api.github.com/users/robbyrussell/orgs","repos_url":"https://api.github.com/users/robbyrussell/repos","events_url":"https://api.github.com/users/robbyrussell/events{/privacy}","received_events_url":"https://api.github.com/users/robbyrussell/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/robbyrussell/oh-my-zsh","description":"A delightful community-driven framework for managing your zsh configuration. Includes 200+ optional plugins (rails, git, OSX, hub, capistrano, brew, ant, php, python, etc), over 140 themes to spice up your morning, and an auto-update tool so that makes it easy to keep up with the latest updates from the community.","fork":false,"url":"https://api.github.com/repos/robbyrussell/oh-my-zsh","forks_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/forks","keys_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/teams","hooks_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/hooks","issue_events_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/issues/events{/number}","events_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/events","assignees_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/assignees{/user}","branches_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/branches{/branch}","tags_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/tags","blobs_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/git/refs{/sha}","trees_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/statuses/{sha}","languages_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/languages","stargazers_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/stargazers","contributors_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/contributors","subscribers_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/subscribers","subscription_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/subscription","commits_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/commits{/sha}","git_commits_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/git/commits{/sha}","comments_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/comments{/number}","issue_comment_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/issues/comments{/number}","contents_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/contents/{+path}","compare_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/merges","archive_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/downloads","issues_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/issues{/number}","pulls_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/pulls{/number}","milestones_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/milestones{/number}","notifications_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/labels{/name}","releases_url":"https://api.github.com/repos/robbyrussell/oh-my-zsh/releases{/id}","created_at":"2009-08-28T18:15:37Z","updated_at":"2015-10-18T16:41:46Z","pushed_at":"2015-10-18T15:36:18Z","git_url":"git://github.com/robbyrussell/oh-my-zsh.git","ssh_url":"git@github.com:robbyrussell/oh-my-zsh.git","clone_url":"https://github.com/robbyrussell/oh-my-zsh.git","svn_url":"https://github.com/robbyrussell/oh-my-zsh","homepage":"http://ohmyz.sh/","size":30735,"stargazers_count":29007,"watchers_count":29007,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8428,"mirror_url":null,"open_issues_count":607,"forks":8428,"open_issues":607,"watchers":29007,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/robbyrussell/oh-my-zsh/pulls/4515"},"html":{"href":"https://github.com/robbyrussell/oh-my-zsh/pull/4515"},"issue":{"href":"https://api.github.com/repos/robbyrussell/oh-my-zsh/issues/4515"},"comments":{"href":"https://api.github.com/repos/robbyrussell/oh-my-zsh/issues/4515/comments"},"review_comments":{"href":"https://api.github.com/repos/robbyrussell/oh-my-zsh/pulls/4515/comments"},"review_comment":{"href":"https://api.github.com/repos/robbyrussell/oh-my-zsh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/robbyrussell/oh-my-zsh/pulls/4515/commits"},"statuses":{"href":"https://api.github.com/repos/robbyrussell/oh-my-zsh/statuses/e8946ce8111c21f75c4787756573b8d24866d73e"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":102,"deletions":98,"changed_files":1}}