Skip to content

Commit

Permalink
search: better handling for invalid query (fixes #634
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesampson committed Jan 14, 2016
1 parent c98e8b6 commit bf02470
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions libexec/scoop-search.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,21 @@ function search_bucket($bucket, $query) {
@{ name = $_ }
}

if($query) { $apps = $apps | ? {
if($_.name -match $query) { return $true }
$bin = bin_match (manifest $_.name $bucket) $query
if($bin) {
$_.bin = $bin; return $true;
if($query) {
try {
$query = new-object regex $query
} catch {
abort "invalid regular expression: $($_.exception.innerexception.message)"
}
} }

$apps = $apps | ? {
if($_.name -match $query) { return $true }
$bin = bin_match (manifest $_.name $bucket) $query
if($bin) {
$_.bin = $bin; return $true;
}
}
}
$apps | % { $_.version = (latest_version $_.name $bucket); $_ }
}

Expand Down

0 comments on commit bf02470

Please sign in to comment.