{"action":"created","issue":{"url":"https://api.github.com/repos/Homebrew/homebrew/issues/50173","repository_url":"https://api.github.com/repos/Homebrew/homebrew","labels_url":"https://api.github.com/repos/Homebrew/homebrew/issues/50173/labels{/name}","comments_url":"https://api.github.com/repos/Homebrew/homebrew/issues/50173/comments","events_url":"https://api.github.com/repos/Homebrew/homebrew/issues/50173/events","html_url":"https://github.com/Homebrew/homebrew/pull/50173","id":141410086,"number":50173,"title":"Improve error message for invalid regex to search","user":{"login":"wannabefro","id":2521383,"avatar_url":"https://avatars.githubusercontent.com/u/2521383?v=3","gravatar_id":"","url":"https://api.github.com/users/wannabefro","html_url":"https://github.com/wannabefro","followers_url":"https://api.github.com/users/wannabefro/followers","following_url":"https://api.github.com/users/wannabefro/following{/other_user}","gists_url":"https://api.github.com/users/wannabefro/gists{/gist_id}","starred_url":"https://api.github.com/users/wannabefro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wannabefro/subscriptions","organizations_url":"https://api.github.com/users/wannabefro/orgs","repos_url":"https://api.github.com/users/wannabefro/repos","events_url":"https://api.github.com/users/wannabefro/events{/privacy}","received_events_url":"https://api.github.com/users/wannabefro/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Homebrew/homebrew/labels/features","name":"features","color":"DDDDDD"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-16T21:41:52Z","updated_at":"2016-03-17T10:30:25Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Homebrew/homebrew/pulls/50173","html_url":"https://github.com/Homebrew/homebrew/pull/50173","diff_url":"https://github.com/Homebrew/homebrew/pull/50173.diff","patch_url":"https://github.com/Homebrew/homebrew/pull/50173.patch"},"body":"### All Submissions:\r\n\r\n- [x] Have you followed the guidelines in our [Contributing](https://github.com/Homebrew/homebrew/blob/master/.github/CONTRIBUTING.md) document?\r\n- [x] Have you checked to ensure there aren't other open [Pull Requests](https://github.com/Homebrew/homebrew/pulls) for the same update/change?\r\n\r\n### Changes to Homebrew's Core:\r\n\r\n- [x] Have you added an explanation of what your changes do and why you'd like us to include them?\r\n- [x] Have you written new tests for your core changes, as applicable? [Here's an example](https://github.com/Homebrew/homebrew/pull/49031) if you'd like one.\r\n- [x] Have you successfully ran `brew tests` with your changes locally?\r\n\r\nFixes Homebrew#50131\r\n\r\nPreviously if a bad regexp was passed to `brew search` it would produce\r\nan output of:\r\n\r\n```\r\n$ brew search '/++[/'\r\nError: target of repeat operator is not specified: /++[/\r\nPlease report this bug:\r\n    https://git.io/brew-troubleshooting\r\n/usr/local/Library/Homebrew/cmd/search.rb:93:in `initialize'\r\n/usr/local/Library/Homebrew/cmd/search.rb:93:in `new'\r\n/usr/local/Library/Homebrew/cmd/search.rb:93:in `query_regexp'\r\n/usr/local/Library/Homebrew/cmd/search.rb:43:in `search'\r\n/usr/local/Library/brew.rb:83:in `<main>'\r\n$\r\n```\r\n\r\nThis commit makes it so that if `Regexp.new` is passed an invalid\r\nregular expression that the error message now looks something like:\r\n\r\n```\r\n$ brew search '/++[/'\r\n/++[/ is not a valid regex\r\n$\r\n```\r\n\r\nI couldn't find any tests around the search command but am more than welcome to add any as needed.\r\n\r\nI thought about whether it was worth rescuing all errors related to invalid regular expressions in this manner as you do in `brew.rb` but felt that since this was specifically related to the search command it wasn't necessary.\r\n\r\nLet me know any feedback on it. Thanks!"},"comment":{"url":"https://api.github.com/repos/Homebrew/homebrew/issues/comments/197809292","html_url":"https://github.com/Homebrew/homebrew/pull/50173#issuecomment-197809292","issue_url":"https://api.github.com/repos/Homebrew/homebrew/issues/50173","id":197809292,"user":{"login":"apjanke","id":2618447,"avatar_url":"https://avatars.githubusercontent.com/u/2618447?v=3","gravatar_id":"","url":"https://api.github.com/users/apjanke","html_url":"https://github.com/apjanke","followers_url":"https://api.github.com/users/apjanke/followers","following_url":"https://api.github.com/users/apjanke/following{/other_user}","gists_url":"https://api.github.com/users/apjanke/gists{/gist_id}","starred_url":"https://api.github.com/users/apjanke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apjanke/subscriptions","organizations_url":"https://api.github.com/users/apjanke/orgs","repos_url":"https://api.github.com/users/apjanke/repos","events_url":"https://api.github.com/users/apjanke/events{/privacy}","received_events_url":"https://api.github.com/users/apjanke/received_events","type":"User","site_admin":false},"created_at":"2016-03-17T10:30:25Z","updated_at":"2016-03-17T10:30:25Z","body":"You're welcome!\r\n\r\nUhh, to clarify, I meant including examples in just the PR description here on GitHub, not in the commit message itself. We like to keep those pretty concise; two or three lines of description is sufficient, in addition to any \"Fixes/Closes #XXXX\" lines. (People might be scrolling through lists of multiple commits, and Homebrew has a *lot* of those. But when focusing on a single PR it helps to have more detail.) Sorry about that. Do you mind amending this again to give it a shorter commit message?\r\n\r\n(The PR's summary just uses the commit message as the default text; you can revise or add stuff to the PR without changing the commit message. For example, normally I'll craft a really concise message for the commit, push it to my branch & make a PR, and then add a lot more explanatory text to the PR, drag in some screenshots, whatever.)\r\n\r\nOther than that nitpick, looks great!"}}