play.pl: exception handling

fix "file not found" error
This commit is contained in:
wowaname 2016-10-02 11:49:55 +00:00
parent 6ba1657fd4
commit c78c75783c
1 changed files with 2 additions and 2 deletions

View File

@ -96,7 +96,7 @@ sub cmd_play {
return weechat::WEECHAT_RC_OK;
}
if ($path and open FH, "<", (($file !~ m"/") ? $path->match :
if ($path = $path->match and open FH, "<", (($file !~ m"/") ? $path :
weechat::config_get_plugin('dir')."/$file")) {
while (<FH>) {
s/[\r\n]*$//;
@ -110,7 +110,7 @@ sub cmd_play {
'play', $buffer);
} else {
weechat::print($buffer, weechat::prefix('error').
"Cannot open '$file': $!");
"Cannot open '$file'".($! ? ": $!" : ""));
return weechat::WEECHAT_RC_ERROR;
}