diff --git a/fhem/FHEM/90_at.pm b/fhem/FHEM/90_at.pm index 62aed421f..12d4e3ec2 100755 --- a/fhem/FHEM/90_at.pm +++ b/fhem/FHEM/90_at.pm @@ -103,7 +103,8 @@ at_Exec($) delete $attr{$name}{skip_next} if($skip); my (undef, $command) = split("[ \t]+", $defs{$name}{DEF}, 2); $command = SemicolonEscape($command); - AnalyzeCommandChain(undef, $command) if(!$skip && !$disable); + my $ret = AnalyzeCommandChain(undef, $command) if(!$skip && !$disable); + Log 3, $ret if($ret); return if(!$defs{$name}); # Deleted in the Command diff --git a/fhem/FHEM/91_notify.pm b/fhem/FHEM/91_notify.pm index bd0ec489f..e70d36fa9 100755 --- a/fhem/FHEM/91_notify.pm +++ b/fhem/FHEM/91_notify.pm @@ -79,6 +79,7 @@ notify_Exec($$) $exec =~ s/____/@/g; my $r = AnalyzeCommandChain(undef, $exec); + Log 3, $r if($r); $ret .= " $r" if($r); } } diff --git a/fhem/FHEM/91_watchdog.pm b/fhem/FHEM/91_watchdog.pm index 4af6753f4..73f5156ea 100755 --- a/fhem/FHEM/91_watchdog.pm +++ b/fhem/FHEM/91_watchdog.pm @@ -95,7 +95,8 @@ watchdog_Trigger($) my $exec = SemicolonEscape($ntfy->{CMD});; $ntfy->{STATE} = "triggered"; $ntfy->{INWATCHDOG} = 1; - AnalyzeCommandChain(undef, $exec); + my $ret = AnalyzeCommandChain(undef, $exec); + Log 3, $ret if($ret); $ntfy->{INWATCHDOG} = 0; } diff --git a/fhem/fhem.pl b/fhem/fhem.pl index 951c2955b..e2709a70d 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -154,14 +154,13 @@ my %client; # Client array my $rcvdquit; # Used for quit handling in init files my $sig_term = 0; # if set to 1, terminate (saving the state) my $modpath_set; # Check if modpath was used, and report if not. -my $global_cl; # To use from perl snippets my %defaultattr; # Default attributes my %intAt; # Internal at timer hash. my $nextat; # Time when next timer will be triggered. my $intAtCnt=0; my %duplicate; # Pool of received msg for multi-fhz/cul setups my $duplidx=0; # helper for the above pool -my $cvsid = '$Id: fhem.pl,v 1.106 2010-05-14 12:19:31 rudolfkoenig Exp $'; +my $cvsid = '$Id: fhem.pl,v 1.107 2010-05-18 08:08:53 rudolfkoenig Exp $'; my $namedef = "where is either:\n" . "- a single device name\n" . @@ -544,13 +543,17 @@ sub AnalyzeCommandChain($$) { my ($c, $cmd) = @_; + my $ret = ""; + $cmd =~ s/#.*$//s; $cmd =~ s/;;/____/g; foreach my $subcmd (split(";", $cmd)) { $subcmd =~ s/____/;/g; - AnalyzeCommand($c, $subcmd); + my $lret = AnalyzeCommand($c, $subcmd); + $ret .= $lret if(defined($lret)); last if($c && !defined($client{$c})); # quit } + return $ret; } ##################################### @@ -583,16 +586,9 @@ AnalyzeCommand($$) $month++; $year+=1900; - $global_cl = $cl; my $ret = eval $cmd; $ret = $@ if($@); - if($ret) { - if($cl) { - syswrite($client{$cl}{fd}, "$ret\n") - } else { - Log 3, $ret; - } - } + syswrite($client{$cl}{fd}, "$ret\n") if($ret && $cl); return $ret; } @@ -635,13 +631,7 @@ AnalyzeCommand($$) my $ret = &{$cmds{$fn}{Fn} }($cl, $param); use strict "refs"; - if($ret) { - if($cl) { - syswrite($client{$cl}{fd}, $ret . "\n"); - } else { - Log 3, $ret; - } - } + syswrite($client{$cl}{fd}, $ret . "\n") if($ret && $cl); return $ret; } @@ -1979,15 +1969,7 @@ sub fhem($) { my $param = shift; - return AnalyzeCommandChain($global_cl, $param); -} - -# the "old" name, kept to make upgrade process easier -sub -fhz($) -{ - my $param = shift; - return AnalyzeCommandChain($global_cl, $param); + return AnalyzeCommandChain(undef, $param); } #####################################