{"action":"created","comment":{"url":"https://api.github.com/repos/joyent/smartos-live/pulls/comments/27906139","id":27906139,"diff_hunk":"@@ -141,52 +222,221 @@ is_net()\n \t[ $c -lt 0 ] && return 1\n \t[ $c -gt 255 ] && return 1\n \t[ $d -lt 0 ] && return 1\n-\t# Make sure the last field isn't the broadcast addr.\n-\t[ $d -ge 255 ] && return 1\n+\treturn 0\n+}\n+\n+# Tests if input is an email address\n+is_email() {\n+\tregex=\"^[a-z0-9!#\\$%&'*+/=?^_\\`{|}~-]+(\\.[a-z0-9!#$%&'*+/=?^_\\`{|}~-]+)*@([a-z0-9]([a-z0-9-]*[a-z0-9])?\\.?)+[a-z0-9]([a-z0-9-]*[a-z0-9])?\\$\"\n+\tADDRESS=$1\n+\n+\t[[ $ADDRESS =~ $regex ]] && return 0\n+\treturn 1\n+}\n+\n+# You can call this like:\n+#\n+#  value=$(getanswer \"foo\")\n+#  [[ $? == 0 ]] || fatal \"no answer for question foo\"\n+#\n+getanswer()\n+{\n+\tlocal key=$1\n+\tlocal answer=\"\"\n+\tlocal potential=\"\"\n+\n+\tif [[ -z ${answer_file} ]]; then\n+\t\treturn ${ENOTFOUND}\n+\tfi\n+\n+\t# json does not distingush between an empty string and a key that's not\n+\t# there with the normal output, so we fix that so we can distinguish.\n+\tanswer=$(/usr/bin/cat ${answer_file} \\\n+\t\t| /usr/bin/json -e \"if (this['${key}'] === undefined) this['${key}'] = '<<undefined>>';\" \\\n+\t\t\"${key}\" 2>&1)\n+\tif [[ $? != 0 ]]; then\n+\t\tif [[ -n $(echo \"${answer}\" | grep \"input is not JSON\") ]]; then\n+\t\t\treturn ${EBADJSON}\n+\t\telse\n+\t\t\treturn ${EUNKNOWN}\n+\t\tfi\n+\tfi\n+\n+\tif [[ ${answer} == \"<<undefined>>\" ]]; then\n+\t\treturn ${ENOTFOUND}\n+\tfi\n+\n+\techo \"${answer}\"\n \treturn 0\n }\n \n # Optional input\n promptopt()\n {\n-\tval=\n-\tprintf \"%s [press enter for none]: \" \"$1\"\n+\tval=\"\"\n+\tdef=\"$2\"\n+\tkey=\"$3\"\n+\n+\tif [[ -n ${key} ]]; then\n+\t\tval=$(getanswer \"${key}\")\n+\t\tif [[ $? == 0 ]]; then\n+\t\t\tif [[ ${val} == \"<default>\" ]]; then\n+\t\t\t\tval=${def}\n+\t\t\tfi\n+\t\t\treturn\n+\t\tfi\n+\tfi\n+\n+\tif [ -z \"$def\" ]; then","path":"overlay/generic/smartdc/lib/smartos_prompt_config.sh","position":307,"original_position":307,"commit_id":"b6f824fae7ebc779ba889cdeae9c280a9ffba7df","original_commit_id":"b6f824fae7ebc779ba889cdeae9c280a9ffba7df","user":{"login":"bahamas10","id":1205722,"avatar_url":"https://avatars.githubusercontent.com/u/1205722?v=3","gravatar_id":"","url":"https://api.github.com/users/bahamas10","html_url":"https://github.com/bahamas10","followers_url":"https://api.github.com/users/bahamas10/followers","following_url":"https://api.github.com/users/bahamas10/following{/other_user}","gists_url":"https://api.github.com/users/bahamas10/gists{/gist_id}","starred_url":"https://api.github.com/users/bahamas10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bahamas10/subscriptions","organizations_url":"https://api.github.com/users/bahamas10/orgs","repos_url":"https://api.github.com/users/bahamas10/repos","events_url":"https://api.github.com/users/bahamas10/events{/privacy}","received_events_url":"https://api.github.com/users/bahamas10/received_events","type":"User","site_admin":false},"body":"personally, i'd prefer `[[` over `[` as it is a builtin and more robust than `[`... see http://mywiki.wooledge.org/BashFAQ/031 for more info\r\n\r\nalso, quotes around `$def` are not needed if `[[ ... ]]` is used.","created_at":"2015-04-07T18:28:08Z","updated_at":"2015-04-07T18:28:08Z","html_url":"https://github.com/joyent/smartos-live/pull/439#discussion_r27906139","pull_request_url":"https://api.github.com/repos/joyent/smartos-live/pulls/439","_links":{"self":{"href":"https://api.github.com/repos/joyent/smartos-live/pulls/comments/27906139"},"html":{"href":"https://github.com/joyent/smartos-live/pull/439#discussion_r27906139"},"pull_request":{"href":"https://api.github.com/repos/joyent/smartos-live/pulls/439"}}},"pull_request":{"url":"https://api.github.com/repos/joyent/smartos-live/pulls/439","id":32785904,"html_url":"https://github.com/joyent/smartos-live/pull/439","diff_url":"https://github.com/joyent/smartos-live/pull/439.diff","patch_url":"https://github.com/joyent/smartos-live/pull/439.patch","issue_url":"https://api.github.com/repos/joyent/smartos-live/issues/439","number":439,"state":"open","locked":false,"title":"Want improved installer","user":{"login":"nshalman","id":20391,"avatar_url":"https://avatars.githubusercontent.com/u/20391?v=3","gravatar_id":"","url":"https://api.github.com/users/nshalman","html_url":"https://github.com/nshalman","followers_url":"https://api.github.com/users/nshalman/followers","following_url":"https://api.github.com/users/nshalman/following{/other_user}","gists_url":"https://api.github.com/users/nshalman/gists{/gist_id}","starred_url":"https://api.github.com/users/nshalman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nshalman/subscriptions","organizations_url":"https://api.github.com/users/nshalman/orgs","repos_url":"https://api.github.com/users/nshalman/repos","events_url":"https://api.github.com/users/nshalman/events{/privacy}","received_events_url":"https://api.github.com/users/nshalman/received_events","type":"User","site_admin":false},"body":"This is a cleaned up version of work originally done by @rmustacc.\r\n@sjorge and I have both done a fair amount of testing of this code in my hourly builds.","created_at":"2015-04-07T17:24:02Z","updated_at":"2015-04-07T18:28:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"af005de11f1d969a13d73cac5d289fbbd2f52ff1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/joyent/smartos-live/pulls/439/commits","review_comments_url":"https://api.github.com/repos/joyent/smartos-live/pulls/439/comments","review_comment_url":"https://api.github.com/repos/joyent/smartos-live/pulls/comments{/number}","comments_url":"https://api.github.com/repos/joyent/smartos-live/issues/439/comments","statuses_url":"https://api.github.com/repos/joyent/smartos-live/statuses/b6f824fae7ebc779ba889cdeae9c280a9ffba7df","head":{"label":"nshalman:new_installer","ref":"new_installer","sha":"b6f824fae7ebc779ba889cdeae9c280a9ffba7df","user":{"login":"nshalman","id":20391,"avatar_url":"https://avatars.githubusercontent.com/u/20391?v=3","gravatar_id":"","url":"https://api.github.com/users/nshalman","html_url":"https://github.com/nshalman","followers_url":"https://api.github.com/users/nshalman/followers","following_url":"https://api.github.com/users/nshalman/following{/other_user}","gists_url":"https://api.github.com/users/nshalman/gists{/gist_id}","starred_url":"https://api.github.com/users/nshalman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nshalman/subscriptions","organizations_url":"https://api.github.com/users/nshalman/orgs","repos_url":"https://api.github.com/users/nshalman/repos","events_url":"https://api.github.com/users/nshalman/events{/privacy}","received_events_url":"https://api.github.com/users/nshalman/received_events","type":"User","site_admin":false},"repo":{"id":4158458,"name":"smartos-live","full_name":"nshalman/smartos-live","owner":{"login":"nshalman","id":20391,"avatar_url":"https://avatars.githubusercontent.com/u/20391?v=3","gravatar_id":"","url":"https://api.github.com/users/nshalman","html_url":"https://github.com/nshalman","followers_url":"https://api.github.com/users/nshalman/followers","following_url":"https://api.github.com/users/nshalman/following{/other_user}","gists_url":"https://api.github.com/users/nshalman/gists{/gist_id}","starred_url":"https://api.github.com/users/nshalman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nshalman/subscriptions","organizations_url":"https://api.github.com/users/nshalman/orgs","repos_url":"https://api.github.com/users/nshalman/repos","events_url":"https://api.github.com/users/nshalman/events{/privacy}","received_events_url":"https://api.github.com/users/nshalman/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nshalman/smartos-live","description":"For more information, please see http://smartos.org/  For any questions that aren't answered there, please join the SmartOS discussion list: http://smartos.org/smartos-mailing-list/","fork":true,"url":"https://api.github.com/repos/nshalman/smartos-live","forks_url":"https://api.github.com/repos/nshalman/smartos-live/forks","keys_url":"https://api.github.com/repos/nshalman/smartos-live/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nshalman/smartos-live/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nshalman/smartos-live/teams","hooks_url":"https://api.github.com/repos/nshalman/smartos-live/hooks","issue_events_url":"https://api.github.com/repos/nshalman/smartos-live/issues/events{/number}","events_url":"https://api.github.com/repos/nshalman/smartos-live/events","assignees_url":"https://api.github.com/repos/nshalman/smartos-live/assignees{/user}","branches_url":"https://api.github.com/repos/nshalman/smartos-live/branches{/branch}","tags_url":"https://api.github.com/repos/nshalman/smartos-live/tags","blobs_url":"https://api.github.com/repos/nshalman/smartos-live/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nshalman/smartos-live/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nshalman/smartos-live/git/refs{/sha}","trees_url":"https://api.github.com/repos/nshalman/smartos-live/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nshalman/smartos-live/statuses/{sha}","languages_url":"https://api.github.com/repos/nshalman/smartos-live/languages","stargazers_url":"https://api.github.com/repos/nshalman/smartos-live/stargazers","contributors_url":"https://api.github.com/repos/nshalman/smartos-live/contributors","subscribers_url":"https://api.github.com/repos/nshalman/smartos-live/subscribers","subscription_url":"https://api.github.com/repos/nshalman/smartos-live/subscription","commits_url":"https://api.github.com/repos/nshalman/smartos-live/commits{/sha}","git_commits_url":"https://api.github.com/repos/nshalman/smartos-live/git/commits{/sha}","comments_url":"https://api.github.com/repos/nshalman/smartos-live/comments{/number}","issue_comment_url":"https://api.github.com/repos/nshalman/smartos-live/issues/comments{/number}","contents_url":"https://api.github.com/repos/nshalman/smartos-live/contents/{+path}","compare_url":"https://api.github.com/repos/nshalman/smartos-live/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nshalman/smartos-live/merges","archive_url":"https://api.github.com/repos/nshalman/smartos-live/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nshalman/smartos-live/downloads","issues_url":"https://api.github.com/repos/nshalman/smartos-live/issues{/number}","pulls_url":"https://api.github.com/repos/nshalman/smartos-live/pulls{/number}","milestones_url":"https://api.github.com/repos/nshalman/smartos-live/milestones{/number}","notifications_url":"https://api.github.com/repos/nshalman/smartos-live/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nshalman/smartos-live/labels{/name}","releases_url":"https://api.github.com/repos/nshalman/smartos-live/releases{/id}","created_at":"2012-04-27T13:19:28Z","updated_at":"2015-02-04T18:38:44Z","pushed_at":"2015-04-07T17:31:25Z","git_url":"git://github.com/nshalman/smartos-live.git","ssh_url":"git@github.com:nshalman/smartos-live.git","clone_url":"https://github.com/nshalman/smartos-live.git","svn_url":"https://github.com/nshalman/smartos-live","homepage":"http://smartos.org","size":33695,"stargazers_count":1,"watchers_count":1,"language":"C","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":"joyent:master","ref":"master","sha":"4ac47122a17379fc993c0bc68f791021b9a301a6","user":{"login":"joyent","id":10161,"avatar_url":"https://avatars.githubusercontent.com/u/10161?v=3","gravatar_id":"","url":"https://api.github.com/users/joyent","html_url":"https://github.com/joyent","followers_url":"https://api.github.com/users/joyent/followers","following_url":"https://api.github.com/users/joyent/following{/other_user}","gists_url":"https://api.github.com/users/joyent/gists{/gist_id}","starred_url":"https://api.github.com/users/joyent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joyent/subscriptions","organizations_url":"https://api.github.com/users/joyent/orgs","repos_url":"https://api.github.com/users/joyent/repos","events_url":"https://api.github.com/users/joyent/events{/privacy}","received_events_url":"https://api.github.com/users/joyent/received_events","type":"Organization","site_admin":false},"repo":{"id":2203782,"name":"smartos-live","full_name":"joyent/smartos-live","owner":{"login":"joyent","id":10161,"avatar_url":"https://avatars.githubusercontent.com/u/10161?v=3","gravatar_id":"","url":"https://api.github.com/users/joyent","html_url":"https://github.com/joyent","followers_url":"https://api.github.com/users/joyent/followers","following_url":"https://api.github.com/users/joyent/following{/other_user}","gists_url":"https://api.github.com/users/joyent/gists{/gist_id}","starred_url":"https://api.github.com/users/joyent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joyent/subscriptions","organizations_url":"https://api.github.com/users/joyent/orgs","repos_url":"https://api.github.com/users/joyent/repos","events_url":"https://api.github.com/users/joyent/events{/privacy}","received_events_url":"https://api.github.com/users/joyent/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/joyent/smartos-live","description":"For more information, please see http://smartos.org/  For any questions that aren't answered there, please join the SmartOS discussion list: http://smartos.org/smartos-mailing-list/","fork":false,"url":"https://api.github.com/repos/joyent/smartos-live","forks_url":"https://api.github.com/repos/joyent/smartos-live/forks","keys_url":"https://api.github.com/repos/joyent/smartos-live/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joyent/smartos-live/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joyent/smartos-live/teams","hooks_url":"https://api.github.com/repos/joyent/smartos-live/hooks","issue_events_url":"https://api.github.com/repos/joyent/smartos-live/issues/events{/number}","events_url":"https://api.github.com/repos/joyent/smartos-live/events","assignees_url":"https://api.github.com/repos/joyent/smartos-live/assignees{/user}","branches_url":"https://api.github.com/repos/joyent/smartos-live/branches{/branch}","tags_url":"https://api.github.com/repos/joyent/smartos-live/tags","blobs_url":"https://api.github.com/repos/joyent/smartos-live/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joyent/smartos-live/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joyent/smartos-live/git/refs{/sha}","trees_url":"https://api.github.com/repos/joyent/smartos-live/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joyent/smartos-live/statuses/{sha}","languages_url":"https://api.github.com/repos/joyent/smartos-live/languages","stargazers_url":"https://api.github.com/repos/joyent/smartos-live/stargazers","contributors_url":"https://api.github.com/repos/joyent/smartos-live/contributors","subscribers_url":"https://api.github.com/repos/joyent/smartos-live/subscribers","subscription_url":"https://api.github.com/repos/joyent/smartos-live/subscription","commits_url":"https://api.github.com/repos/joyent/smartos-live/commits{/sha}","git_commits_url":"https://api.github.com/repos/joyent/smartos-live/git/commits{/sha}","comments_url":"https://api.github.com/repos/joyent/smartos-live/comments{/number}","issue_comment_url":"https://api.github.com/repos/joyent/smartos-live/issues/comments{/number}","contents_url":"https://api.github.com/repos/joyent/smartos-live/contents/{+path}","compare_url":"https://api.github.com/repos/joyent/smartos-live/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joyent/smartos-live/merges","archive_url":"https://api.github.com/repos/joyent/smartos-live/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joyent/smartos-live/downloads","issues_url":"https://api.github.com/repos/joyent/smartos-live/issues{/number}","pulls_url":"https://api.github.com/repos/joyent/smartos-live/pulls{/number}","milestones_url":"https://api.github.com/repos/joyent/smartos-live/milestones{/number}","notifications_url":"https://api.github.com/repos/joyent/smartos-live/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joyent/smartos-live/labels{/name}","releases_url":"https://api.github.com/repos/joyent/smartos-live/releases{/id}","created_at":"2011-08-14T01:08:28Z","updated_at":"2015-04-07T16:33:28Z","pushed_at":"2015-04-07T17:24:32Z","git_url":"git://github.com/joyent/smartos-live.git","ssh_url":"git@github.com:joyent/smartos-live.git","clone_url":"https://github.com/joyent/smartos-live.git","svn_url":"https://github.com/joyent/smartos-live","homepage":"","size":38638,"stargazers_count":846,"watchers_count":846,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":131,"mirror_url":null,"open_issues_count":177,"forks":131,"open_issues":177,"watchers":846,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/joyent/smartos-live/pulls/439"},"html":{"href":"https://github.com/joyent/smartos-live/pull/439"},"issue":{"href":"https://api.github.com/repos/joyent/smartos-live/issues/439"},"comments":{"href":"https://api.github.com/repos/joyent/smartos-live/issues/439/comments"},"review_comments":{"href":"https://api.github.com/repos/joyent/smartos-live/pulls/439/comments"},"review_comment":{"href":"https://api.github.com/repos/joyent/smartos-live/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/joyent/smartos-live/pulls/439/commits"},"statuses":{"href":"https://api.github.com/repos/joyent/smartos-live/statuses/b6f824fae7ebc779ba889cdeae9c280a9ffba7df"}}}}