{"action":"created","issue":{"url":"https://api.github.com/repos/koalaman/shellcheck/issues/319","labels_url":"https://api.github.com/repos/koalaman/shellcheck/issues/319/labels{/name}","comments_url":"https://api.github.com/repos/koalaman/shellcheck/issues/319/comments","events_url":"https://api.github.com/repos/koalaman/shellcheck/issues/319/events","html_url":"https://github.com/koalaman/shellcheck/issues/319","id":59405026,"number":319,"title":"SC2143: Possible wrong suggestion","user":{"login":"bayandin","id":864213,"avatar_url":"https://avatars.githubusercontent.com/u/864213?v=3","gravatar_id":"","url":"https://api.github.com/users/bayandin","html_url":"https://github.com/bayandin","followers_url":"https://api.github.com/users/bayandin/followers","following_url":"https://api.github.com/users/bayandin/following{/other_user}","gists_url":"https://api.github.com/users/bayandin/gists{/gist_id}","starred_url":"https://api.github.com/users/bayandin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bayandin/subscriptions","organizations_url":"https://api.github.com/users/bayandin/orgs","repos_url":"https://api.github.com/users/bayandin/repos","events_url":"https://api.github.com/users/bayandin/events{/privacy}","received_events_url":"https://api.github.com/users/bayandin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-01T16:48:29Z","updated_at":"2015-03-01T20:28:16Z","closed_at":"2015-03-01T20:23:28Z","body":"In my code I used this condition:\r\n```bash\r\nif [ -z \"$(grep 'Europe/Moscow' /etc/timezone)\" ]; then\r\n    echo Europe/Moscow > /etc/timezone\r\n    dpkg-reconfigure --frontend noninteractive tzdata\r\nfi\r\n```\r\n\r\nShellcheck catches this with the following suggestion:\r\n```bash\r\nif [ -z \"$(grep 'Europe/Moscow' /etc/timezone)\" ]; then\r\n     ^-- SC2143: Instead of [ -z $(foo | grep bar) ], use ! foo | grep -q bar .\r\n```\r\n\r\nMy first reaction was fix my condition by something like this:\r\n```bash\r\nif ! /etc/timezone | grep -q 'Europe/Moscow'; then\r\n...\r\n```\r\nBut the right way it is a\r\n```\r\nif ! grep -q 'Europe/Moscow' /etc/timezone; then\r\n...\r\n```\r\n\r\nIt would be better if shellcheck can split cases like `cmd | grep smth` and `grep smth filename`."},"comment":{"url":"https://api.github.com/repos/koalaman/shellcheck/issues/comments/76628616","html_url":"https://github.com/koalaman/shellcheck/issues/319#issuecomment-76628616","issue_url":"https://api.github.com/repos/koalaman/shellcheck/issues/319","id":76628616,"user":{"login":"bayandin","id":864213,"avatar_url":"https://avatars.githubusercontent.com/u/864213?v=3","gravatar_id":"","url":"https://api.github.com/users/bayandin","html_url":"https://github.com/bayandin","followers_url":"https://api.github.com/users/bayandin/followers","following_url":"https://api.github.com/users/bayandin/following{/other_user}","gists_url":"https://api.github.com/users/bayandin/gists{/gist_id}","starred_url":"https://api.github.com/users/bayandin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bayandin/subscriptions","organizations_url":"https://api.github.com/users/bayandin/orgs","repos_url":"https://api.github.com/users/bayandin/repos","events_url":"https://api.github.com/users/bayandin/events{/privacy}","received_events_url":"https://api.github.com/users/bayandin/received_events","type":"User","site_admin":false},"created_at":"2015-03-01T20:28:16Z","updated_at":"2015-03-01T20:28:16Z","body":"Awesome! Thanks."}}