{"action":"created","issue":{"url":"https://api.github.com/repos/koalaman/shellcheck/issues/255","labels_url":"https://api.github.com/repos/koalaman/shellcheck/issues/255/labels{/name}","comments_url":"https://api.github.com/repos/koalaman/shellcheck/issues/255/comments","events_url":"https://api.github.com/repos/koalaman/shellcheck/issues/255/events","html_url":"https://github.com/koalaman/shellcheck/issues/255","id":48226124,"number":255,"title":"Bash arithmetic expansion diagnostics","user":{"login":"mietek","id":166207,"avatar_url":"https://avatars.githubusercontent.com/u/166207?v=3","gravatar_id":"","url":"https://api.github.com/users/mietek","html_url":"https://github.com/mietek","followers_url":"https://api.github.com/users/mietek/followers","following_url":"https://api.github.com/users/mietek/following{/other_user}","gists_url":"https://api.github.com/users/mietek/gists{/gist_id}","starred_url":"https://api.github.com/users/mietek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mietek/subscriptions","organizations_url":"https://api.github.com/users/mietek/orgs","repos_url":"https://api.github.com/users/mietek/repos","events_url":"https://api.github.com/users/mietek/events{/privacy}","received_events_url":"https://api.github.com/users/mietek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-11-10T03:14:39Z","updated_at":"2015-01-02T21:40:40Z","closed_at":null,"body":"```\r\nIn src/deploy.sh line 130:\r\n        deploy_time=(( time_after - time_before ))\r\n                    ^-- SC1056: Expected a '}'. If you have one, try a ; or \\n in front of it.\r\n                    ^-- SC1036: '(' is invalid here. Did you forget to escape it?\r\n                    ^-- SC1072: Unexpected \"(\". Fix any mentioned problems and try again.\r\n                     ^-- SC1036: '(' is invalid here. Did you forget to escape it?\r\n```\r\nThe problem here is a missing `$` before the `((`.  ShellCheck’s diagnostics appear to be misleading in this case."},"comment":{"url":"https://api.github.com/repos/koalaman/shellcheck/issues/comments/68564987","html_url":"https://github.com/koalaman/shellcheck/issues/255#issuecomment-68564987","issue_url":"https://api.github.com/repos/koalaman/shellcheck/issues/255","id":68564987,"user":{"login":"ormaaj","id":255938,"avatar_url":"https://avatars.githubusercontent.com/u/255938?v=3","gravatar_id":"","url":"https://api.github.com/users/ormaaj","html_url":"https://github.com/ormaaj","followers_url":"https://api.github.com/users/ormaaj/followers","following_url":"https://api.github.com/users/ormaaj/following{/other_user}","gists_url":"https://api.github.com/users/ormaaj/gists{/gist_id}","starred_url":"https://api.github.com/users/ormaaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ormaaj/subscriptions","organizations_url":"https://api.github.com/users/ormaaj/orgs","repos_url":"https://api.github.com/users/ormaaj/repos","events_url":"https://api.github.com/users/ormaaj/events{/privacy}","received_events_url":"https://api.github.com/users/ormaaj/received_events","type":"User","site_admin":false},"created_at":"2015-01-02T21:40:40Z","updated_at":"2015-01-02T21:40:40Z","body":"That might be tricky, because the parsing rules for array assignments are complex. In `bash`, `x=((...))` is a special case of an invalid array assignment containing unescaped metacharacters. in `ksh93`, `a=((foo))` is a perfectly valid array assignment to `a[0][0]`. And of course, it's also perfectly legal to have unescaped metacharacters even in bash array assignments such as `typeset -ia a=([(x + y) * z]=foo`.\r\n\r\nIt's also a special case of some closely related bugs (IMO).  Bash incorrectly considers `a=(foo)bar` a valid string assignment and fails to split the assignment at the metacharacter `)`. ksh runs the `bar` command with a benign array export assignment (like bash would do if it split the words). In any shell without arrays it's just a plain invalid assignment.\r\n\r\nAnyway, just sayin there's a lot to consider. I don't think just checking for `a=(())` and assuming they meant `$(())` is a good idea."}}