{"action":"opened","issue":{"url":"https://api.github.com/repos/koalaman/shellcheck/issues/1415","repository_url":"https://api.github.com/repos/koalaman/shellcheck","labels_url":"https://api.github.com/repos/koalaman/shellcheck/issues/1415/labels{/name}","comments_url":"https://api.github.com/repos/koalaman/shellcheck/issues/1415/comments","events_url":"https://api.github.com/repos/koalaman/shellcheck/issues/1415/events","html_url":"https://github.com/koalaman/shellcheck/issues/1415","id":390829211,"node_id":"MDU6SXNzdWUzOTA4MjkyMTE=","number":1415,"title":"[A-Z] pattern matches depends on locale in bash.","user":{"login":"mhoes","id":14194483,"node_id":"MDQ6VXNlcjE0MTk0NDgz","avatar_url":"https://avatars0.githubusercontent.com/u/14194483?v=4","gravatar_id":"","url":"https://api.github.com/users/mhoes","html_url":"https://github.com/mhoes","followers_url":"https://api.github.com/users/mhoes/followers","following_url":"https://api.github.com/users/mhoes/following{/other_user}","gists_url":"https://api.github.com/users/mhoes/gists{/gist_id}","starred_url":"https://api.github.com/users/mhoes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhoes/subscriptions","organizations_url":"https://api.github.com/users/mhoes/orgs","repos_url":"https://api.github.com/users/mhoes/repos","events_url":"https://api.github.com/users/mhoes/events{/privacy}","received_events_url":"https://api.github.com/users/mhoes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-13T19:40:13Z","updated_at":"2018-12-13T19:40:13Z","closed_at":null,"author_association":"NONE","body":"I tried this on shellcheck.net online, and got no results (no issues found), and I expected to get a warning.\r\n\r\nConsider the following shellscript\r\n\r\n```sh\r\n#!/bin/bash\r\nfor i in \"$@\"; do\r\n  case \"$i\" in\r\n    *[A-Z]*) echo \"$i has upper case\";;\r\n  esac\r\ndone\r\n\r\n```\r\n\r\nIn dash, mksh, ksh, and zsh, this will always produce the following output (regardless of locale) :\r\n\r\n$ env - LANG=en_US.UTF-8 /bin/dash ./Demo a b C y z\r\nC has upper case\r\n\r\n\r\nBut in bash, the results will depend on the locale that is set. For example, when LANG is set to en_US.UTF-8, you will get the following results :\r\n\r\n$ env - LANG=en_US.UTF-8 /bin/bash ./Demo a b C y z\r\nb has upper case\r\nC has upper case\r\ny has upper case\r\nz has upper case\r\n\r\n\r\nThe rationale/reason for this is that the bash developers feel that this is how character sets work, and since the locale specifies the ordering, under this locale, [A-Z] means: [AbBcCdD..zZ] (that's why it doesn't match 'a', and does match 'y' and 'z'). In bash, the only locale guaranteed to have that ordering for ranges ([a-z], [A-Z], ...) is the POSIX locale (LANG=C or LANG=POSIX). If you always want the set of upper case characters in bash regardless of locale, you need to use [:upper:] instead of [A-Z] (or explicitly set LANG to C or POSIX).\r\n\r\n\r\n#### Here's what shellcheck currently says:\r\nNo issues detected!\r\n\r\n\r\n#### Here's what I wanted or expected to see:\r\nA warning, stating that when using bash, either use [:upper:] instead of [A-Z] and [:lower:] instead of [a-z], or explicitly set LANG to either C or POSIX.\r\n\r\n"}}
{"actor":{"display_login":"mhoes"}}