play.pl: fix bug for paths with /

This commit is contained in:
wowaname 2016-10-03 01:01:48 +00:00
parent 1158390ac5
commit 3e9e72d1f8

View File

@ -92,16 +92,19 @@ sub cmd_play {
: weechat::config_integer($prio_s) : weechat::config_integer($prio_s)
) or 10); ) or 10);
my $path = File::Find::Rule->file->name($file) my $rule = File::Find::Rule->file->name($file)
->start(weechat::config_get_plugin('dir')); ->start(weechat::config_get_plugin('dir'));
if ($find) { if ($find) {
weechat::print($buffer, " \t$_") while defined( $_ = $path->match ); weechat::print($buffer, " \t$_") while defined( $_ = $rule->match );
return weechat::WEECHAT_RC_OK; return weechat::WEECHAT_RC_OK;
} }
if ($path = $path->match and open FH, "<", (($file !~ m"/") ? $path : my $path;
weechat::config_get_plugin('dir')."/$file")) { if ($file =~ m"/") { $path = weechat::config_get_plugin('dir')."/$file" }
else { $path = $rule->match }
if ($path and open FH, "<", $path) {
my @lines; my @lines;
push @lines, s/[\r\n]*$//r while <FH>; push @lines, s/[\r\n]*$//r while <FH>;
close FH; close FH;