Re: [PATCH 1/2] Add / command in add --patch (feature request)
- From
Jeff King <peff@peff.net>
- Date
- Nov 26, 2008, 22:38 UTC
- Message-ID
- <20081126223858.GB10786@coredump.intra.peff.net>
- In-Reply-To
- <492DB6C8.7010205@gmail.com>
On Wed, Nov 26, 2008 at 08:51:20PM +0000, William Pursell wrote:
> This is naive, and it is easy for an invalid
> search string to cause a perl error.
> [...]
> + if( $text !~ $search_s ) {Yeah, a bad regex will cause the whole program to barf. Maybe wrap it in an eval, like this?
my $r = eval { $text !~ $search_s };
if ($@) {
print STDERR "error in search string: $@\n";
next;
}
if ($r) {
...Or similar (I didn't look at the code closely enough to know if "next" is the right thing there).
-Peff