{"action":"created","comment":{"url":"https://api.github.com/repos/denysdovhan/bash-handbook/pulls/comments/52062866","id":52062866,"diff_hunk":"@@ -231,6 +232,77 @@ Variables may also have _default_ values. We can define as such using the follow\n FOO=${FOO:-'default'}\n ```\n \n+# Shell expansions\n+\n+_Expansions_ are performed on the command line after it has been split into _tokens_. In other words, these expansions are mechanism to calculate arithmetical operations, to save results of command's executions and so on.\n+\n+If you are interested, you can read [more about shell expansions](https://www.gnu.org/software/bash/manual/bash.html#Shell-Expansions).\n+\n+## Brace expansion\n+\n+Brace expansion allow us to generate arbitrary strings. It's similar to _filename expansion_. For example:\n+\n+```bash\n+echo beg{i,a,u}n # begin began begun\n+```\n+\n+Also brace expansions may be used for creating ranges, which are iterated over in loops.\n+\n+```bash\n+echo {0..5} # 0 1 2 3 4 5\n+echo {00..8..2} # 00 02 04 06 08\n+```\n+\n+## Command substitution\n+\n+Command substitution allow us to evaluate a command and substitute its value into another command or variable assignment. Command substitution is performed when a command is enclosed by `` `​` `` or `$()`.  For example, we can use it as follows:\n+\n+```bash\n+now=`date +%T`\n+# or\n+now=$(date +%T)\n+\n+echo $now # 19:08:26\n+```\n+\n+## Arithmetic expansion\n+\n+In bash we are free to do any arithmetical operations. But the expression must enclosed by `$(( ))` The format for arithmetic expansions is:\n+\n+```bash\n+result=$(( ((10 + 5*3) - 7) / 2 ))\n+echo $result # 9\n+```\n+\n+## Double and single quotes\n+\n+There is an important difference between double and single quotes. Inside double quotes variables or command substitutions are expanded. Inside single quotes they are not. For example:\n+\n+```bash\n+echo \"Your home: $HOME\" # Your home: /Users/<username>\n+echo 'Your home: $HOME' # Your home: $HOME\n+```\n+\n+Take care to expand local variables and environment variables within quotes if they could contain whitespace. As an innocuous example, consider `echo`-ing some user input:\n+\n+```bash\n+INPUT=\"A string  with   strange    whitespace.\"\n+echo $INPUT   # yields: A string with strange whitespace.\n+echo \"$INPUT\" # yields: A string  with   strange    whitespace.\n+```\n+\n+The first `echo` is invoked with 5 separate arguments--$INPUT is split into separate words, `echo` prints a single space character between each. In the second case, `echo` is invoked with a single argument (the entire $INPUT value, including whitespace).","path":"README.md","position":86,"original_position":86,"commit_id":"ef19284c1c9bcf631198f69930a96510951f6151","original_commit_id":"ef19284c1c9bcf631198f69930a96510951f6151","user":{"login":"denysdovhan","id":3459374,"avatar_url":"https://avatars.githubusercontent.com/u/3459374?v=3","gravatar_id":"","url":"https://api.github.com/users/denysdovhan","html_url":"https://github.com/denysdovhan","followers_url":"https://api.github.com/users/denysdovhan/followers","following_url":"https://api.github.com/users/denysdovhan/following{/other_user}","gists_url":"https://api.github.com/users/denysdovhan/gists{/gist_id}","starred_url":"https://api.github.com/users/denysdovhan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/denysdovhan/subscriptions","organizations_url":"https://api.github.com/users/denysdovhan/orgs","repos_url":"https://api.github.com/users/denysdovhan/repos","events_url":"https://api.github.com/users/denysdovhan/events{/privacy}","received_events_url":"https://api.github.com/users/denysdovhan/received_events","type":"User","site_admin":false},"body":"Do not use `--` if you mean dash. Just use dash `—`.","created_at":"2016-02-05T19:39:53Z","updated_at":"2016-02-05T19:39:53Z","html_url":"https://github.com/denysdovhan/bash-handbook/pull/37#discussion_r52062866","pull_request_url":"https://api.github.com/repos/denysdovhan/bash-handbook/pulls/37","_links":{"self":{"href":"https://api.github.com/repos/denysdovhan/bash-handbook/pulls/comments/52062866"},"html":{"href":"https://github.com/denysdovhan/bash-handbook/pull/37#discussion_r52062866"},"pull_request":{"href":"https://api.github.com/repos/denysdovhan/bash-handbook/pulls/37"}}},"pull_request":{"url":"https://api.github.com/repos/denysdovhan/bash-handbook/pulls/37","id":57778052,"html_url":"https://github.com/denysdovhan/bash-handbook/pull/37","diff_url":"https://github.com/denysdovhan/bash-handbook/pull/37.diff","patch_url":"https://github.com/denysdovhan/bash-handbook/pull/37.patch","issue_url":"https://api.github.com/repos/denysdovhan/bash-handbook/issues/37","number":37,"state":"open","locked":false,"title":"Use defensive quoting in examples","user":{"login":"sumbach","id":11580,"avatar_url":"https://avatars.githubusercontent.com/u/11580?v=3","gravatar_id":"","url":"https://api.github.com/users/sumbach","html_url":"https://github.com/sumbach","followers_url":"https://api.github.com/users/sumbach/followers","following_url":"https://api.github.com/users/sumbach/following{/other_user}","gists_url":"https://api.github.com/users/sumbach/gists{/gist_id}","starred_url":"https://api.github.com/users/sumbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumbach/subscriptions","organizations_url":"https://api.github.com/users/sumbach/orgs","repos_url":"https://api.github.com/users/sumbach/repos","events_url":"https://api.github.com/users/sumbach/events{/privacy}","received_events_url":"https://api.github.com/users/sumbach/received_events","type":"User","site_admin":false},"body":"It's really hard to get quoting right in bash scripts. While the quotes may not be absolutely necessary in these examples, it's better to have them in place to encourage good behavior (and help anyone who copies, pastes, and modifies these examples).","created_at":"2016-01-31T19:48:18Z","updated_at":"2016-02-05T19:39:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c7cd5662cda08bbbe2677fb8a8654e7b2b408181","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/denysdovhan/bash-handbook/pulls/37/commits","review_comments_url":"https://api.github.com/repos/denysdovhan/bash-handbook/pulls/37/comments","review_comment_url":"https://api.github.com/repos/denysdovhan/bash-handbook/pulls/comments{/number}","comments_url":"https://api.github.com/repos/denysdovhan/bash-handbook/issues/37/comments","statuses_url":"https://api.github.com/repos/denysdovhan/bash-handbook/statuses/ef19284c1c9bcf631198f69930a96510951f6151","head":{"label":"sumbach:patch-11","ref":"patch-11","sha":"ef19284c1c9bcf631198f69930a96510951f6151","user":{"login":"sumbach","id":11580,"avatar_url":"https://avatars.githubusercontent.com/u/11580?v=3","gravatar_id":"","url":"https://api.github.com/users/sumbach","html_url":"https://github.com/sumbach","followers_url":"https://api.github.com/users/sumbach/followers","following_url":"https://api.github.com/users/sumbach/following{/other_user}","gists_url":"https://api.github.com/users/sumbach/gists{/gist_id}","starred_url":"https://api.github.com/users/sumbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumbach/subscriptions","organizations_url":"https://api.github.com/users/sumbach/orgs","repos_url":"https://api.github.com/users/sumbach/repos","events_url":"https://api.github.com/users/sumbach/events{/privacy}","received_events_url":"https://api.github.com/users/sumbach/received_events","type":"User","site_admin":false},"repo":{"id":50790525,"name":"bash-handbook","full_name":"sumbach/bash-handbook","owner":{"login":"sumbach","id":11580,"avatar_url":"https://avatars.githubusercontent.com/u/11580?v=3","gravatar_id":"","url":"https://api.github.com/users/sumbach","html_url":"https://github.com/sumbach","followers_url":"https://api.github.com/users/sumbach/followers","following_url":"https://api.github.com/users/sumbach/following{/other_user}","gists_url":"https://api.github.com/users/sumbach/gists{/gist_id}","starred_url":"https://api.github.com/users/sumbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sumbach/subscriptions","organizations_url":"https://api.github.com/users/sumbach/orgs","repos_url":"https://api.github.com/users/sumbach/repos","events_url":"https://api.github.com/users/sumbach/events{/privacy}","received_events_url":"https://api.github.com/users/sumbach/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sumbach/bash-handbook","description":"For those who wanna learn Bash","fork":true,"url":"https://api.github.com/repos/sumbach/bash-handbook","forks_url":"https://api.github.com/repos/sumbach/bash-handbook/forks","keys_url":"https://api.github.com/repos/sumbach/bash-handbook/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sumbach/bash-handbook/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sumbach/bash-handbook/teams","hooks_url":"https://api.github.com/repos/sumbach/bash-handbook/hooks","issue_events_url":"https://api.github.com/repos/sumbach/bash-handbook/issues/events{/number}","events_url":"https://api.github.com/repos/sumbach/bash-handbook/events","assignees_url":"https://api.github.com/repos/sumbach/bash-handbook/assignees{/user}","branches_url":"https://api.github.com/repos/sumbach/bash-handbook/branches{/branch}","tags_url":"https://api.github.com/repos/sumbach/bash-handbook/tags","blobs_url":"https://api.github.com/repos/sumbach/bash-handbook/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sumbach/bash-handbook/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sumbach/bash-handbook/git/refs{/sha}","trees_url":"https://api.github.com/repos/sumbach/bash-handbook/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sumbach/bash-handbook/statuses/{sha}","languages_url":"https://api.github.com/repos/sumbach/bash-handbook/languages","stargazers_url":"https://api.github.com/repos/sumbach/bash-handbook/stargazers","contributors_url":"https://api.github.com/repos/sumbach/bash-handbook/contributors","subscribers_url":"https://api.github.com/repos/sumbach/bash-handbook/subscribers","subscription_url":"https://api.github.com/repos/sumbach/bash-handbook/subscription","commits_url":"https://api.github.com/repos/sumbach/bash-handbook/commits{/sha}","git_commits_url":"https://api.github.com/repos/sumbach/bash-handbook/git/commits{/sha}","comments_url":"https://api.github.com/repos/sumbach/bash-handbook/comments{/number}","issue_comment_url":"https://api.github.com/repos/sumbach/bash-handbook/issues/comments{/number}","contents_url":"https://api.github.com/repos/sumbach/bash-handbook/contents/{+path}","compare_url":"https://api.github.com/repos/sumbach/bash-handbook/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sumbach/bash-handbook/merges","archive_url":"https://api.github.com/repos/sumbach/bash-handbook/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sumbach/bash-handbook/downloads","issues_url":"https://api.github.com/repos/sumbach/bash-handbook/issues{/number}","pulls_url":"https://api.github.com/repos/sumbach/bash-handbook/pulls{/number}","milestones_url":"https://api.github.com/repos/sumbach/bash-handbook/milestones{/number}","notifications_url":"https://api.github.com/repos/sumbach/bash-handbook/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sumbach/bash-handbook/labels{/name}","releases_url":"https://api.github.com/repos/sumbach/bash-handbook/releases{/id}","deployments_url":"https://api.github.com/repos/sumbach/bash-handbook/deployments","created_at":"2016-01-31T19:15:40Z","updated_at":"2016-01-31T19:15:41Z","pushed_at":"2016-02-05T18:44:53Z","git_url":"git://github.com/sumbach/bash-handbook.git","ssh_url":"git@github.com:sumbach/bash-handbook.git","clone_url":"https://github.com/sumbach/bash-handbook.git","svn_url":"https://github.com/sumbach/bash-handbook","homepage":"https://git.io/bash-handbook","size":59,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"denysdovhan:master","ref":"master","sha":"fe19957c443957cbc0cf1c90defb254764101494","user":{"login":"denysdovhan","id":3459374,"avatar_url":"https://avatars.githubusercontent.com/u/3459374?v=3","gravatar_id":"","url":"https://api.github.com/users/denysdovhan","html_url":"https://github.com/denysdovhan","followers_url":"https://api.github.com/users/denysdovhan/followers","following_url":"https://api.github.com/users/denysdovhan/following{/other_user}","gists_url":"https://api.github.com/users/denysdovhan/gists{/gist_id}","starred_url":"https://api.github.com/users/denysdovhan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/denysdovhan/subscriptions","organizations_url":"https://api.github.com/users/denysdovhan/orgs","repos_url":"https://api.github.com/users/denysdovhan/repos","events_url":"https://api.github.com/users/denysdovhan/events{/privacy}","received_events_url":"https://api.github.com/users/denysdovhan/received_events","type":"User","site_admin":false},"repo":{"id":48818677,"name":"bash-handbook","full_name":"denysdovhan/bash-handbook","owner":{"login":"denysdovhan","id":3459374,"avatar_url":"https://avatars.githubusercontent.com/u/3459374?v=3","gravatar_id":"","url":"https://api.github.com/users/denysdovhan","html_url":"https://github.com/denysdovhan","followers_url":"https://api.github.com/users/denysdovhan/followers","following_url":"https://api.github.com/users/denysdovhan/following{/other_user}","gists_url":"https://api.github.com/users/denysdovhan/gists{/gist_id}","starred_url":"https://api.github.com/users/denysdovhan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/denysdovhan/subscriptions","organizations_url":"https://api.github.com/users/denysdovhan/orgs","repos_url":"https://api.github.com/users/denysdovhan/repos","events_url":"https://api.github.com/users/denysdovhan/events{/privacy}","received_events_url":"https://api.github.com/users/denysdovhan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/denysdovhan/bash-handbook","description":"For those who wanna learn Bash","fork":false,"url":"https://api.github.com/repos/denysdovhan/bash-handbook","forks_url":"https://api.github.com/repos/denysdovhan/bash-handbook/forks","keys_url":"https://api.github.com/repos/denysdovhan/bash-handbook/keys{/key_id}","collaborators_url":"https://api.github.com/repos/denysdovhan/bash-handbook/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/denysdovhan/bash-handbook/teams","hooks_url":"https://api.github.com/repos/denysdovhan/bash-handbook/hooks","issue_events_url":"https://api.github.com/repos/denysdovhan/bash-handbook/issues/events{/number}","events_url":"https://api.github.com/repos/denysdovhan/bash-handbook/events","assignees_url":"https://api.github.com/repos/denysdovhan/bash-handbook/assignees{/user}","branches_url":"https://api.github.com/repos/denysdovhan/bash-handbook/branches{/branch}","tags_url":"https://api.github.com/repos/denysdovhan/bash-handbook/tags","blobs_url":"https://api.github.com/repos/denysdovhan/bash-handbook/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/denysdovhan/bash-handbook/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/denysdovhan/bash-handbook/git/refs{/sha}","trees_url":"https://api.github.com/repos/denysdovhan/bash-handbook/git/trees{/sha}","statuses_url":"https://api.github.com/repos/denysdovhan/bash-handbook/statuses/{sha}","languages_url":"https://api.github.com/repos/denysdovhan/bash-handbook/languages","stargazers_url":"https://api.github.com/repos/denysdovhan/bash-handbook/stargazers","contributors_url":"https://api.github.com/repos/denysdovhan/bash-handbook/contributors","subscribers_url":"https://api.github.com/repos/denysdovhan/bash-handbook/subscribers","subscription_url":"https://api.github.com/repos/denysdovhan/bash-handbook/subscription","commits_url":"https://api.github.com/repos/denysdovhan/bash-handbook/commits{/sha}","git_commits_url":"https://api.github.com/repos/denysdovhan/bash-handbook/git/commits{/sha}","comments_url":"https://api.github.com/repos/denysdovhan/bash-handbook/comments{/number}","issue_comment_url":"https://api.github.com/repos/denysdovhan/bash-handbook/issues/comments{/number}","contents_url":"https://api.github.com/repos/denysdovhan/bash-handbook/contents/{+path}","compare_url":"https://api.github.com/repos/denysdovhan/bash-handbook/compare/{base}...{head}","merges_url":"https://api.github.com/repos/denysdovhan/bash-handbook/merges","archive_url":"https://api.github.com/repos/denysdovhan/bash-handbook/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/denysdovhan/bash-handbook/downloads","issues_url":"https://api.github.com/repos/denysdovhan/bash-handbook/issues{/number}","pulls_url":"https://api.github.com/repos/denysdovhan/bash-handbook/pulls{/number}","milestones_url":"https://api.github.com/repos/denysdovhan/bash-handbook/milestones{/number}","notifications_url":"https://api.github.com/repos/denysdovhan/bash-handbook/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/denysdovhan/bash-handbook/labels{/name}","releases_url":"https://api.github.com/repos/denysdovhan/bash-handbook/releases{/id}","deployments_url":"https://api.github.com/repos/denysdovhan/bash-handbook/deployments","created_at":"2015-12-30T20:41:00Z","updated_at":"2016-02-05T19:03:29Z","pushed_at":"2016-02-05T18:44:53Z","git_url":"git://github.com/denysdovhan/bash-handbook.git","ssh_url":"git@github.com:denysdovhan/bash-handbook.git","clone_url":"https://github.com/denysdovhan/bash-handbook.git","svn_url":"https://github.com/denysdovhan/bash-handbook","homepage":"https://git.io/bash-handbook","size":86,"stargazers_count":1802,"watchers_count":1802,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":104,"mirror_url":null,"open_issues_count":15,"forks":104,"open_issues":15,"watchers":1802,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/denysdovhan/bash-handbook/pulls/37"},"html":{"href":"https://github.com/denysdovhan/bash-handbook/pull/37"},"issue":{"href":"https://api.github.com/repos/denysdovhan/bash-handbook/issues/37"},"comments":{"href":"https://api.github.com/repos/denysdovhan/bash-handbook/issues/37/comments"},"review_comments":{"href":"https://api.github.com/repos/denysdovhan/bash-handbook/pulls/37/comments"},"review_comment":{"href":"https://api.github.com/repos/denysdovhan/bash-handbook/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/denysdovhan/bash-handbook/pulls/37/commits"},"statuses":{"href":"https://api.github.com/repos/denysdovhan/bash-handbook/statuses/ef19284c1c9bcf631198f69930a96510951f6151"}}}}