{"action":"created","comment":{"url":"https://api.github.com/repos/mvdan/sh/pulls/comments/156131917","pull_request_review_id":82560572,"id":156131917,"diff_hunk":"@@ -553,3 +595,45 @@ func (r *Runner) relPath(path string) string {\n \t}\n \treturn filepath.Clean(path)\n }\n+\n+type getopts struct {\n+\targidx  int\n+\truneidx int\n+}\n+\n+func (g *getopts) Next(optstr string, args []string) (opt rune, optarg string, done bool) {\n+\tif len(args) == 0 || g.argidx >= len(args) {\n+\t\treturn '?', \"\", true\n+\t}\n+\targ := []rune(args[g.argidx])\n+\tif len(arg) < 2 || arg[0] != '-' || arg[1] == '-' {\n+\t\treturn '?', \"\", true\n+\t}\n+\n+\topts := arg[1:]\n+\topt = opts[g.runeidx]\n+\tif g.runeidx+1 < len(opts) {\n+\t\tg.runeidx += 1\n+\t} else {\n+\t\tg.argidx += 1\n+\t\tg.runeidx = 0\n+\t}\n+\n+\ti := strings.IndexRune(optstr, opt)\n+\tif i == -1 {","path":"interp/builtin.go","position":82,"original_position":82,"commit_id":"6e94d40dde9d0b46d69dfca8580fae1bc9ce8b5a","original_commit_id":"6e94d40dde9d0b46d69dfca8580fae1bc9ce8b5a","user":{"login":"ebfe","id":685065,"avatar_url":"https://avatars1.githubusercontent.com/u/685065?v=4","gravatar_id":"","url":"https://api.github.com/users/ebfe","html_url":"https://github.com/ebfe","followers_url":"https://api.github.com/users/ebfe/followers","following_url":"https://api.github.com/users/ebfe/following{/other_user}","gists_url":"https://api.github.com/users/ebfe/gists{/gist_id}","starred_url":"https://api.github.com/users/ebfe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebfe/subscriptions","organizations_url":"https://api.github.com/users/ebfe/orgs","repos_url":"https://api.github.com/users/ebfe/repos","events_url":"https://api.github.com/users/ebfe/events{/privacy}","received_events_url":"https://api.github.com/users/ebfe/received_events","type":"User","site_admin":false},"body":"done","created_at":"2017-12-11T16:53:14Z","updated_at":"2017-12-11T16:53:14Z","html_url":"https://github.com/mvdan/sh/pull/197#discussion_r156131917","pull_request_url":"https://api.github.com/repos/mvdan/sh/pulls/197","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/mvdan/sh/pulls/comments/156131917"},"html":{"href":"https://github.com/mvdan/sh/pull/197#discussion_r156131917"},"pull_request":{"href":"https://api.github.com/repos/mvdan/sh/pulls/197"}},"in_reply_to_id":156126604},"pull_request":{"url":"https://api.github.com/repos/mvdan/sh/pulls/197","id":157607872,"html_url":"https://github.com/mvdan/sh/pull/197","diff_url":"https://github.com/mvdan/sh/pull/197.diff","patch_url":"https://github.com/mvdan/sh/pull/197.patch","issue_url":"https://api.github.com/repos/mvdan/sh/issues/197","number":197,"state":"open","locked":false,"title":"interp: support getopts","user":{"login":"ebfe","id":685065,"avatar_url":"https://avatars1.githubusercontent.com/u/685065?v=4","gravatar_id":"","url":"https://api.github.com/users/ebfe","html_url":"https://github.com/ebfe","followers_url":"https://api.github.com/users/ebfe/followers","following_url":"https://api.github.com/users/ebfe/following{/other_user}","gists_url":"https://api.github.com/users/ebfe/gists{/gist_id}","starred_url":"https://api.github.com/users/ebfe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebfe/subscriptions","organizations_url":"https://api.github.com/users/ebfe/orgs","repos_url":"https://api.github.com/users/ebfe/repos","events_url":"https://api.github.com/users/ebfe/events{/privacy}","received_events_url":"https://api.github.com/users/ebfe/received_events","type":"User","site_admin":false},"body":"Initial attempt at the getopts builtin. Tracking state across multiple getopts\ninvocations is a bit ugly (necessary for -abc shortcuts) and so is detecting\nintervening assignments to OPTIND. State split into a separate getopts struct in\nthe hope it could be used to handle options to the builtins too.","created_at":"2017-12-11T16:22:10Z","updated_at":"2017-12-11T16:53:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0c602c27d6e9696e5f948dc31b244db848a6bd3a","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/mvdan/sh/pulls/197/commits","review_comments_url":"https://api.github.com/repos/mvdan/sh/pulls/197/comments","review_comment_url":"https://api.github.com/repos/mvdan/sh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mvdan/sh/issues/197/comments","statuses_url":"https://api.github.com/repos/mvdan/sh/statuses/6e94d40dde9d0b46d69dfca8580fae1bc9ce8b5a","head":{"label":"ebfe:getopts","ref":"getopts","sha":"6e94d40dde9d0b46d69dfca8580fae1bc9ce8b5a","user":{"login":"ebfe","id":685065,"avatar_url":"https://avatars1.githubusercontent.com/u/685065?v=4","gravatar_id":"","url":"https://api.github.com/users/ebfe","html_url":"https://github.com/ebfe","followers_url":"https://api.github.com/users/ebfe/followers","following_url":"https://api.github.com/users/ebfe/following{/other_user}","gists_url":"https://api.github.com/users/ebfe/gists{/gist_id}","starred_url":"https://api.github.com/users/ebfe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebfe/subscriptions","organizations_url":"https://api.github.com/users/ebfe/orgs","repos_url":"https://api.github.com/users/ebfe/repos","events_url":"https://api.github.com/users/ebfe/events{/privacy}","received_events_url":"https://api.github.com/users/ebfe/received_events","type":"User","site_admin":false},"repo":{"id":97594517,"name":"sh","full_name":"ebfe/sh","owner":{"login":"ebfe","id":685065,"avatar_url":"https://avatars1.githubusercontent.com/u/685065?v=4","gravatar_id":"","url":"https://api.github.com/users/ebfe","html_url":"https://github.com/ebfe","followers_url":"https://api.github.com/users/ebfe/followers","following_url":"https://api.github.com/users/ebfe/following{/other_user}","gists_url":"https://api.github.com/users/ebfe/gists{/gist_id}","starred_url":"https://api.github.com/users/ebfe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebfe/subscriptions","organizations_url":"https://api.github.com/users/ebfe/orgs","repos_url":"https://api.github.com/users/ebfe/repos","events_url":"https://api.github.com/users/ebfe/events{/privacy}","received_events_url":"https://api.github.com/users/ebfe/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ebfe/sh","description":"A shell parser, formatter and interpreter (POSIX/Bash/mksh)","fork":true,"url":"https://api.github.com/repos/ebfe/sh","forks_url":"https://api.github.com/repos/ebfe/sh/forks","keys_url":"https://api.github.com/repos/ebfe/sh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ebfe/sh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ebfe/sh/teams","hooks_url":"https://api.github.com/repos/ebfe/sh/hooks","issue_events_url":"https://api.github.com/repos/ebfe/sh/issues/events{/number}","events_url":"https://api.github.com/repos/ebfe/sh/events","assignees_url":"https://api.github.com/repos/ebfe/sh/assignees{/user}","branches_url":"https://api.github.com/repos/ebfe/sh/branches{/branch}","tags_url":"https://api.github.com/repos/ebfe/sh/tags","blobs_url":"https://api.github.com/repos/ebfe/sh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ebfe/sh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ebfe/sh/git/refs{/sha}","trees_url":"https://api.github.com/repos/ebfe/sh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ebfe/sh/statuses/{sha}","languages_url":"https://api.github.com/repos/ebfe/sh/languages","stargazers_url":"https://api.github.com/repos/ebfe/sh/stargazers","contributors_url":"https://api.github.com/repos/ebfe/sh/contributors","subscribers_url":"https://api.github.com/repos/ebfe/sh/subscribers","subscription_url":"https://api.github.com/repos/ebfe/sh/subscription","commits_url":"https://api.github.com/repos/ebfe/sh/commits{/sha}","git_commits_url":"https://api.github.com/repos/ebfe/sh/git/commits{/sha}","comments_url":"https://api.github.com/repos/ebfe/sh/comments{/number}","issue_comment_url":"https://api.github.com/repos/ebfe/sh/issues/comments{/number}","contents_url":"https://api.github.com/repos/ebfe/sh/contents/{+path}","compare_url":"https://api.github.com/repos/ebfe/sh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ebfe/sh/merges","archive_url":"https://api.github.com/repos/ebfe/sh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ebfe/sh/downloads","issues_url":"https://api.github.com/repos/ebfe/sh/issues{/number}","pulls_url":"https://api.github.com/repos/ebfe/sh/pulls{/number}","milestones_url":"https://api.github.com/repos/ebfe/sh/milestones{/number}","notifications_url":"https://api.github.com/repos/ebfe/sh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ebfe/sh/labels{/name}","releases_url":"https://api.github.com/repos/ebfe/sh/releases{/id}","deployments_url":"https://api.github.com/repos/ebfe/sh/deployments","created_at":"2017-07-18T12:19:39Z","updated_at":"2017-07-18T12:19:40Z","pushed_at":"2017-12-11T16:15:12Z","git_url":"git://github.com/ebfe/sh.git","ssh_url":"git@github.com:ebfe/sh.git","clone_url":"https://github.com/ebfe/sh.git","svn_url":"https://github.com/ebfe/sh","homepage":"","size":2433,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mvdan:master","ref":"master","sha":"c0880dba61ef75eca289e11825f0b5894d3efb21","user":{"login":"mvdan","id":3576549,"avatar_url":"https://avatars0.githubusercontent.com/u/3576549?v=4","gravatar_id":"","url":"https://api.github.com/users/mvdan","html_url":"https://github.com/mvdan","followers_url":"https://api.github.com/users/mvdan/followers","following_url":"https://api.github.com/users/mvdan/following{/other_user}","gists_url":"https://api.github.com/users/mvdan/gists{/gist_id}","starred_url":"https://api.github.com/users/mvdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvdan/subscriptions","organizations_url":"https://api.github.com/users/mvdan/orgs","repos_url":"https://api.github.com/users/mvdan/repos","events_url":"https://api.github.com/users/mvdan/events{/privacy}","received_events_url":"https://api.github.com/users/mvdan/received_events","type":"User","site_admin":false},"repo":{"id":49766020,"name":"sh","full_name":"mvdan/sh","owner":{"login":"mvdan","id":3576549,"avatar_url":"https://avatars0.githubusercontent.com/u/3576549?v=4","gravatar_id":"","url":"https://api.github.com/users/mvdan","html_url":"https://github.com/mvdan","followers_url":"https://api.github.com/users/mvdan/followers","following_url":"https://api.github.com/users/mvdan/following{/other_user}","gists_url":"https://api.github.com/users/mvdan/gists{/gist_id}","starred_url":"https://api.github.com/users/mvdan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvdan/subscriptions","organizations_url":"https://api.github.com/users/mvdan/orgs","repos_url":"https://api.github.com/users/mvdan/repos","events_url":"https://api.github.com/users/mvdan/events{/privacy}","received_events_url":"https://api.github.com/users/mvdan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mvdan/sh","description":"A shell parser, formatter and interpreter (POSIX/Bash/mksh)","fork":false,"url":"https://api.github.com/repos/mvdan/sh","forks_url":"https://api.github.com/repos/mvdan/sh/forks","keys_url":"https://api.github.com/repos/mvdan/sh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mvdan/sh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mvdan/sh/teams","hooks_url":"https://api.github.com/repos/mvdan/sh/hooks","issue_events_url":"https://api.github.com/repos/mvdan/sh/issues/events{/number}","events_url":"https://api.github.com/repos/mvdan/sh/events","assignees_url":"https://api.github.com/repos/mvdan/sh/assignees{/user}","branches_url":"https://api.github.com/repos/mvdan/sh/branches{/branch}","tags_url":"https://api.github.com/repos/mvdan/sh/tags","blobs_url":"https://api.github.com/repos/mvdan/sh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mvdan/sh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mvdan/sh/git/refs{/sha}","trees_url":"https://api.github.com/repos/mvdan/sh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mvdan/sh/statuses/{sha}","languages_url":"https://api.github.com/repos/mvdan/sh/languages","stargazers_url":"https://api.github.com/repos/mvdan/sh/stargazers","contributors_url":"https://api.github.com/repos/mvdan/sh/contributors","subscribers_url":"https://api.github.com/repos/mvdan/sh/subscribers","subscription_url":"https://api.github.com/repos/mvdan/sh/subscription","commits_url":"https://api.github.com/repos/mvdan/sh/commits{/sha}","git_commits_url":"https://api.github.com/repos/mvdan/sh/git/commits{/sha}","comments_url":"https://api.github.com/repos/mvdan/sh/comments{/number}","issue_comment_url":"https://api.github.com/repos/mvdan/sh/issues/comments{/number}","contents_url":"https://api.github.com/repos/mvdan/sh/contents/{+path}","compare_url":"https://api.github.com/repos/mvdan/sh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mvdan/sh/merges","archive_url":"https://api.github.com/repos/mvdan/sh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mvdan/sh/downloads","issues_url":"https://api.github.com/repos/mvdan/sh/issues{/number}","pulls_url":"https://api.github.com/repos/mvdan/sh/pulls{/number}","milestones_url":"https://api.github.com/repos/mvdan/sh/milestones{/number}","notifications_url":"https://api.github.com/repos/mvdan/sh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mvdan/sh/labels{/name}","releases_url":"https://api.github.com/repos/mvdan/sh/releases{/id}","deployments_url":"https://api.github.com/repos/mvdan/sh/deployments","created_at":"2016-01-16T08:39:09Z","updated_at":"2017-12-10T15:17:50Z","pushed_at":"2017-12-11T16:22:11Z","git_url":"git://github.com/mvdan/sh.git","ssh_url":"git@github.com:mvdan/sh.git","clone_url":"https://github.com/mvdan/sh.git","svn_url":"https://github.com/mvdan/sh","homepage":"","size":2490,"stargazers_count":788,"watchers_count":788,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":34,"mirror_url":null,"archived":false,"open_issues_count":8,"license":{"key":"bsd-3-clause","name":"BSD 3-clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause"},"forks":34,"open_issues":8,"watchers":788,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mvdan/sh/pulls/197"},"html":{"href":"https://github.com/mvdan/sh/pull/197"},"issue":{"href":"https://api.github.com/repos/mvdan/sh/issues/197"},"comments":{"href":"https://api.github.com/repos/mvdan/sh/issues/197/comments"},"review_comments":{"href":"https://api.github.com/repos/mvdan/sh/pulls/197/comments"},"review_comment":{"href":"https://api.github.com/repos/mvdan/sh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mvdan/sh/pulls/197/commits"},"statuses":{"href":"https://api.github.com/repos/mvdan/sh/statuses/6e94d40dde9d0b46d69dfca8580fae1bc9ce8b5a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ebfe"}}