Skip to content

Commit

Permalink
Do not use open2 since it doesn't work really well with HTTP::Server:…
Browse files Browse the repository at this point in the history
…:Simple. Use shell_quote and qx() instead.
  • Loading branch information
miyagawa committed Jun 3, 2009
1 parent 847041e commit efdb9c4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/File/Spotlight.pm
Expand Up @@ -6,7 +6,7 @@ our $VERSION = '0.01';

use Carp;
use Mac::Tie::PList;
use IPC::Open2;
use String::ShellQuote;

sub new {
my $class = shift;
Expand All @@ -33,14 +33,12 @@ sub list {
sub _run_mdfind {
my($self, $path, $query) = @_;

my($out, $in);
my $pid = open2($out, $in, 'mdfind', '-onlyin', $path, $query);
my $cmd = 'mdfind -onlyin ' . shell_quote($path) . ' ' . shell_quote($query);

local $_;
my @files;
while (<$out>) {
for my $file (grep length, split /\n/, qx($cmd)) {
chomp;
push @files, $_;
push @files, $file;
}

return @files;
Expand Down

0 comments on commit efdb9c4

Please sign in to comment.