{"action":"created","comment":{"url":"https://api.github.com/repos/PillarTechnology/bash-practices/pulls/comments/42575785","id":42575785,"diff_hunk":"@@ -1,31 +1,84 @@\n #!/bin/bash -eu\n set -o pipefail\n \n-while [[ $# -ne 0 ]]; do\n-    arg=\"$1\"; shift\n-\n-    case \"$arg\" in\n-        -\\?|-h|--help)\n-            help_message\n-            exit\n-            ;;\n-        --version)\n-            show_version\n-            ;;\n-        --my-arg)\n-            store_myarg\n-            ;;\n-        --tag=*)\n-            val=\"$1\"; shift\n-            store_tag \"$val\"\n-            ;;\n-        -*)\n-            echo >&2 \"$me: illegal option \\`$arg'\"\n-            echo >&2 \"Run '$me --help' for more information\"\n-            exit 1\n-            ;;\n-        *)\n-            store_opt \"$arg\"\n-            ;;\n-    esac\n-done\n+MY_CMD=${BASH_SOURCE[0]}\n+\n+function help_message()\n+{\n+\techo \"Here is where you would place statement to\"\n+\techo \"    print the appropriate help message\"\n+\t\n+\techo \"\"\n+\techo \"try the following different command-lines to see which functions are called:\"\n+\techo \"./argparse --version --my-arg --tag=\\\"Very good\\\"\"\n+\techo \"./argparse --version --my-arg --tag=\\\"VeryGood\\\"\"\n+\techo \"./argparse --version --my-arg --tag= \\\"VeryGood\\\"\"\n+\techo \"./argparse --tag= no --tag= yes option1 option2\"\n+\techo \"./argparse ?\"\n+\techo \"./argparse -?\"\n+\techo \"./argparse --unknown\"\n+\t\n+\techo \"\"\n+\techo \"Notice which command-lines work as expected. Spaces, even in quotes, are parsed\"\n+\techo \"Note that the \\\"--tag= \\\" option needs a space before the parameter.\"\t\n+}\n+\n+function show_version()\n+{\n+\techo \"Here would be where you would print the script version number\"\n+}\n+\n+function store_myarg()\n+{\n+\techo \"The \\\"--my-arg option\\\" has been detected. In this function \"\n+\techo \"    a default parameter might be changed from false to true.\"\n+}\n+\n+function store_tag()\n+{\n+\techo \"The  \\\"--tag= <value>\\\" option has been detected with the\"\n+\techo \"    value \\\"$@\\\". would be assigned to a global variable.\"\n+}\n+\n+function store_opt()\n+{\n+\techo \"An option was detected. Here's where the\"\n+\techo \"    \\\"$@\\\" option would be interpreted and stored for use by the script.\"\n+}\n+\n+function parse_command_line()\n+{\n+\twhile [[ $# -ne 0 ]]; do\n+\t\targ=\"$1\"; shift\n+\n+\t\tcase \"$arg\" in\n+\t\t\t-\\?|-h|--help)\n+\t\t\t\thelp_message\n+\t\t\t\texit\n+\t\t\t\t;;\n+\t\t\t--version)\n+\t\t\t\tshow_version\n+\t\t\t\t;;\n+\t\t\t--my-arg)\n+\t\t\t\tstore_myarg\n+\t\t\t\t;;\n+\t\t\t--tag=*)\n+\t\t\t\tval=\"$1\"; shift","path":"argparse","position":94,"original_position":94,"commit_id":"9f591527278532a3c86bfb98a414bb50e6ae092f","original_commit_id":"9f591527278532a3c86bfb98a414bb50e6ae092f","user":{"login":"ben--","id":3695147,"avatar_url":"https://avatars.githubusercontent.com/u/3695147?v=3","gravatar_id":"","url":"https://api.github.com/users/ben--","html_url":"https://github.com/ben--","followers_url":"https://api.github.com/users/ben--/followers","following_url":"https://api.github.com/users/ben--/following{/other_user}","gists_url":"https://api.github.com/users/ben--/gists{/gist_id}","starred_url":"https://api.github.com/users/ben--/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ben--/subscriptions","organizations_url":"https://api.github.com/users/ben--/orgs","repos_url":"https://api.github.com/users/ben--/repos","events_url":"https://api.github.com/users/ben--/events{/privacy}","received_events_url":"https://api.github.com/users/ben--/received_events","type":"User","site_admin":false},"body":"When reviewing this with Mike last week, I realized there were more than one issue in this file. Specifically, in this case, the value isn't correctly split from the argument.  A better implementation of line 66 would be:\r\n\r\nval=\"$(echo \"$arg\" | cut -f 2- -d =)\"\r\n\r\nand the shift is not necessary....","created_at":"2015-10-21T01:45:50Z","updated_at":"2015-10-21T01:45:50Z","html_url":"https://github.com/PillarTechnology/bash-practices/pull/3#discussion_r42575785","pull_request_url":"https://api.github.com/repos/PillarTechnology/bash-practices/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/PillarTechnology/bash-practices/pulls/comments/42575785"},"html":{"href":"https://github.com/PillarTechnology/bash-practices/pull/3#discussion_r42575785"},"pull_request":{"href":"https://api.github.com/repos/PillarTechnology/bash-practices/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/PillarTechnology/bash-practices/pulls/3","id":48019594,"html_url":"https://github.com/PillarTechnology/bash-practices/pull/3","diff_url":"https://github.com/PillarTechnology/bash-practices/pull/3.diff","patch_url":"https://github.com/PillarTechnology/bash-practices/pull/3.patch","issue_url":"https://api.github.com/repos/PillarTechnology/bash-practices/issues/3","number":3,"state":"open","locked":false,"title":"A fully functioning version to allow developers to experiment with it…","user":{"login":"mtromp","id":1025920,"avatar_url":"https://avatars.githubusercontent.com/u/1025920?v=3","gravatar_id":"","url":"https://api.github.com/users/mtromp","html_url":"https://github.com/mtromp","followers_url":"https://api.github.com/users/mtromp/followers","following_url":"https://api.github.com/users/mtromp/following{/other_user}","gists_url":"https://api.github.com/users/mtromp/gists{/gist_id}","starred_url":"https://api.github.com/users/mtromp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtromp/subscriptions","organizations_url":"https://api.github.com/users/mtromp/orgs","repos_url":"https://api.github.com/users/mtromp/repos","events_url":"https://api.github.com/users/mtromp/events{/privacy}","received_events_url":"https://api.github.com/users/mtromp/received_events","type":"User","site_admin":false},"body":"…s querks","created_at":"2015-10-18T22:21:08Z","updated_at":"2015-10-21T01:45:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d26ce5038e3f1974667f6809ad340f29cdb0d632","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/PillarTechnology/bash-practices/pulls/3/commits","review_comments_url":"https://api.github.com/repos/PillarTechnology/bash-practices/pulls/3/comments","review_comment_url":"https://api.github.com/repos/PillarTechnology/bash-practices/pulls/comments{/number}","comments_url":"https://api.github.com/repos/PillarTechnology/bash-practices/issues/3/comments","statuses_url":"https://api.github.com/repos/PillarTechnology/bash-practices/statuses/9f591527278532a3c86bfb98a414bb50e6ae092f","head":{"label":"mtromp:master","ref":"master","sha":"9f591527278532a3c86bfb98a414bb50e6ae092f","user":{"login":"mtromp","id":1025920,"avatar_url":"https://avatars.githubusercontent.com/u/1025920?v=3","gravatar_id":"","url":"https://api.github.com/users/mtromp","html_url":"https://github.com/mtromp","followers_url":"https://api.github.com/users/mtromp/followers","following_url":"https://api.github.com/users/mtromp/following{/other_user}","gists_url":"https://api.github.com/users/mtromp/gists{/gist_id}","starred_url":"https://api.github.com/users/mtromp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtromp/subscriptions","organizations_url":"https://api.github.com/users/mtromp/orgs","repos_url":"https://api.github.com/users/mtromp/repos","events_url":"https://api.github.com/users/mtromp/events{/privacy}","received_events_url":"https://api.github.com/users/mtromp/received_events","type":"User","site_admin":false},"repo":{"id":43010306,"name":"bash-practices","full_name":"mtromp/bash-practices","owner":{"login":"mtromp","id":1025920,"avatar_url":"https://avatars.githubusercontent.com/u/1025920?v=3","gravatar_id":"","url":"https://api.github.com/users/mtromp","html_url":"https://github.com/mtromp","followers_url":"https://api.github.com/users/mtromp/followers","following_url":"https://api.github.com/users/mtromp/following{/other_user}","gists_url":"https://api.github.com/users/mtromp/gists{/gist_id}","starred_url":"https://api.github.com/users/mtromp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtromp/subscriptions","organizations_url":"https://api.github.com/users/mtromp/orgs","repos_url":"https://api.github.com/users/mtromp/repos","events_url":"https://api.github.com/users/mtromp/events{/privacy}","received_events_url":"https://api.github.com/users/mtromp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mtromp/bash-practices","description":"Good practices for bash code","fork":true,"url":"https://api.github.com/repos/mtromp/bash-practices","forks_url":"https://api.github.com/repos/mtromp/bash-practices/forks","keys_url":"https://api.github.com/repos/mtromp/bash-practices/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mtromp/bash-practices/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mtromp/bash-practices/teams","hooks_url":"https://api.github.com/repos/mtromp/bash-practices/hooks","issue_events_url":"https://api.github.com/repos/mtromp/bash-practices/issues/events{/number}","events_url":"https://api.github.com/repos/mtromp/bash-practices/events","assignees_url":"https://api.github.com/repos/mtromp/bash-practices/assignees{/user}","branches_url":"https://api.github.com/repos/mtromp/bash-practices/branches{/branch}","tags_url":"https://api.github.com/repos/mtromp/bash-practices/tags","blobs_url":"https://api.github.com/repos/mtromp/bash-practices/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mtromp/bash-practices/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mtromp/bash-practices/git/refs{/sha}","trees_url":"https://api.github.com/repos/mtromp/bash-practices/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mtromp/bash-practices/statuses/{sha}","languages_url":"https://api.github.com/repos/mtromp/bash-practices/languages","stargazers_url":"https://api.github.com/repos/mtromp/bash-practices/stargazers","contributors_url":"https://api.github.com/repos/mtromp/bash-practices/contributors","subscribers_url":"https://api.github.com/repos/mtromp/bash-practices/subscribers","subscription_url":"https://api.github.com/repos/mtromp/bash-practices/subscription","commits_url":"https://api.github.com/repos/mtromp/bash-practices/commits{/sha}","git_commits_url":"https://api.github.com/repos/mtromp/bash-practices/git/commits{/sha}","comments_url":"https://api.github.com/repos/mtromp/bash-practices/comments{/number}","issue_comment_url":"https://api.github.com/repos/mtromp/bash-practices/issues/comments{/number}","contents_url":"https://api.github.com/repos/mtromp/bash-practices/contents/{+path}","compare_url":"https://api.github.com/repos/mtromp/bash-practices/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mtromp/bash-practices/merges","archive_url":"https://api.github.com/repos/mtromp/bash-practices/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mtromp/bash-practices/downloads","issues_url":"https://api.github.com/repos/mtromp/bash-practices/issues{/number}","pulls_url":"https://api.github.com/repos/mtromp/bash-practices/pulls{/number}","milestones_url":"https://api.github.com/repos/mtromp/bash-practices/milestones{/number}","notifications_url":"https://api.github.com/repos/mtromp/bash-practices/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mtromp/bash-practices/labels{/name}","releases_url":"https://api.github.com/repos/mtromp/bash-practices/releases{/id}","created_at":"2015-09-23T15:39:40Z","updated_at":"2015-09-23T15:39:41Z","pushed_at":"2015-10-18T22:18:50Z","git_url":"git://github.com/mtromp/bash-practices.git","ssh_url":"git@github.com:mtromp/bash-practices.git","clone_url":"https://github.com/mtromp/bash-practices.git","svn_url":"https://github.com/mtromp/bash-practices","homepage":null,"size":119,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"PillarTechnology:master","ref":"master","sha":"7810c8553a58a67de96df09997ae1b6ea27c4e02","user":{"login":"PillarTechnology","id":484078,"avatar_url":"https://avatars.githubusercontent.com/u/484078?v=3","gravatar_id":"","url":"https://api.github.com/users/PillarTechnology","html_url":"https://github.com/PillarTechnology","followers_url":"https://api.github.com/users/PillarTechnology/followers","following_url":"https://api.github.com/users/PillarTechnology/following{/other_user}","gists_url":"https://api.github.com/users/PillarTechnology/gists{/gist_id}","starred_url":"https://api.github.com/users/PillarTechnology/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PillarTechnology/subscriptions","organizations_url":"https://api.github.com/users/PillarTechnology/orgs","repos_url":"https://api.github.com/users/PillarTechnology/repos","events_url":"https://api.github.com/users/PillarTechnology/events{/privacy}","received_events_url":"https://api.github.com/users/PillarTechnology/received_events","type":"Organization","site_admin":false},"repo":{"id":42999312,"name":"bash-practices","full_name":"PillarTechnology/bash-practices","owner":{"login":"PillarTechnology","id":484078,"avatar_url":"https://avatars.githubusercontent.com/u/484078?v=3","gravatar_id":"","url":"https://api.github.com/users/PillarTechnology","html_url":"https://github.com/PillarTechnology","followers_url":"https://api.github.com/users/PillarTechnology/followers","following_url":"https://api.github.com/users/PillarTechnology/following{/other_user}","gists_url":"https://api.github.com/users/PillarTechnology/gists{/gist_id}","starred_url":"https://api.github.com/users/PillarTechnology/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PillarTechnology/subscriptions","organizations_url":"https://api.github.com/users/PillarTechnology/orgs","repos_url":"https://api.github.com/users/PillarTechnology/repos","events_url":"https://api.github.com/users/PillarTechnology/events{/privacy}","received_events_url":"https://api.github.com/users/PillarTechnology/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/PillarTechnology/bash-practices","description":"Good practices for bash code","fork":false,"url":"https://api.github.com/repos/PillarTechnology/bash-practices","forks_url":"https://api.github.com/repos/PillarTechnology/bash-practices/forks","keys_url":"https://api.github.com/repos/PillarTechnology/bash-practices/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PillarTechnology/bash-practices/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PillarTechnology/bash-practices/teams","hooks_url":"https://api.github.com/repos/PillarTechnology/bash-practices/hooks","issue_events_url":"https://api.github.com/repos/PillarTechnology/bash-practices/issues/events{/number}","events_url":"https://api.github.com/repos/PillarTechnology/bash-practices/events","assignees_url":"https://api.github.com/repos/PillarTechnology/bash-practices/assignees{/user}","branches_url":"https://api.github.com/repos/PillarTechnology/bash-practices/branches{/branch}","tags_url":"https://api.github.com/repos/PillarTechnology/bash-practices/tags","blobs_url":"https://api.github.com/repos/PillarTechnology/bash-practices/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PillarTechnology/bash-practices/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PillarTechnology/bash-practices/git/refs{/sha}","trees_url":"https://api.github.com/repos/PillarTechnology/bash-practices/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PillarTechnology/bash-practices/statuses/{sha}","languages_url":"https://api.github.com/repos/PillarTechnology/bash-practices/languages","stargazers_url":"https://api.github.com/repos/PillarTechnology/bash-practices/stargazers","contributors_url":"https://api.github.com/repos/PillarTechnology/bash-practices/contributors","subscribers_url":"https://api.github.com/repos/PillarTechnology/bash-practices/subscribers","subscription_url":"https://api.github.com/repos/PillarTechnology/bash-practices/subscription","commits_url":"https://api.github.com/repos/PillarTechnology/bash-practices/commits{/sha}","git_commits_url":"https://api.github.com/repos/PillarTechnology/bash-practices/git/commits{/sha}","comments_url":"https://api.github.com/repos/PillarTechnology/bash-practices/comments{/number}","issue_comment_url":"https://api.github.com/repos/PillarTechnology/bash-practices/issues/comments{/number}","contents_url":"https://api.github.com/repos/PillarTechnology/bash-practices/contents/{+path}","compare_url":"https://api.github.com/repos/PillarTechnology/bash-practices/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PillarTechnology/bash-practices/merges","archive_url":"https://api.github.com/repos/PillarTechnology/bash-practices/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PillarTechnology/bash-practices/downloads","issues_url":"https://api.github.com/repos/PillarTechnology/bash-practices/issues{/number}","pulls_url":"https://api.github.com/repos/PillarTechnology/bash-practices/pulls{/number}","milestones_url":"https://api.github.com/repos/PillarTechnology/bash-practices/milestones{/number}","notifications_url":"https://api.github.com/repos/PillarTechnology/bash-practices/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PillarTechnology/bash-practices/labels{/name}","releases_url":"https://api.github.com/repos/PillarTechnology/bash-practices/releases{/id}","created_at":"2015-09-23T12:25:22Z","updated_at":"2015-09-23T12:37:25Z","pushed_at":"2015-10-18T22:21:11Z","git_url":"git://github.com/PillarTechnology/bash-practices.git","ssh_url":"git@github.com:PillarTechnology/bash-practices.git","clone_url":"https://github.com/PillarTechnology/bash-practices.git","svn_url":"https://github.com/PillarTechnology/bash-practices","homepage":null,"size":138,"stargazers_count":0,"watchers_count":0,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/PillarTechnology/bash-practices/pulls/3"},"html":{"href":"https://github.com/PillarTechnology/bash-practices/pull/3"},"issue":{"href":"https://api.github.com/repos/PillarTechnology/bash-practices/issues/3"},"comments":{"href":"https://api.github.com/repos/PillarTechnology/bash-practices/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/PillarTechnology/bash-practices/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/PillarTechnology/bash-practices/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/PillarTechnology/bash-practices/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/PillarTechnology/bash-practices/statuses/9f591527278532a3c86bfb98a414bb50e6ae092f"}}}}