X-Git-Url: https://git.nmode.ca/Fey/blobdiff_plain/9b3457a8dba8fccac63591eef54812994e1178e0..5646894a3a7d5c653d400f9e311438761dcf218e:/lib/App/Fey.pm diff --git a/lib/App/Fey.pm b/lib/App/Fey.pm index 9939a5c..c137002 100644 --- a/lib/App/Fey.pm +++ b/lib/App/Fey.pm @@ -30,16 +30,13 @@ sub launch { die "No files or URIs specified.\n" unless @_; ARG: for my $file_or_uri (@_) { - if ($file_or_uri =~ m|^file://(.+)|) { - $file_or_uri = $1; + if ($options->{fork} && !$options->{single}) { + my $pid = fork; + next ARG if ($pid); } - my ($mime_or_uri, $targets); - if (-e $file_or_uri) { - $mime_or_uri = $self->{mime_query}->($file_or_uri) - } else { - $mime_or_uri = $file_or_uri; - } + $file_or_uri = $1 if ($file_or_uri =~ m|^file://(.+)|); + my $mime_or_uri = -e $file_or_uri ? $self->{mime_query}->($file_or_uri) : $file_or_uri; for my $target (@{ $self->{targets} }) { for my $pattern (@{ $target->{patterns} }) { @@ -52,6 +49,7 @@ sub launch { return; } $associations->{$context}->($file_or_uri); + return if ($options->{fork}); next ARG; } }