Skip to content

Commit

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

if($query) { $apps = $apps | where-object {
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 | where-object {
if($_.name -match $query) { return $true }
$bin = bin_match (manifest $_.name $bucket) $query
if($bin) {
$_.bin = $bin; return $true;
}
}
}
$apps | foreach-object { $_.version = (latest_version $_.name $bucket); $_ }
}

Expand Down

0 comments on commit dbb1f15

Please sign in to comment.