From 7a3ac8ac829220ce156586f48fb2b7350a172a09 Mon Sep 17 00:00:00 2001 From: Jeremy Dechard Date: Mon, 22 Jan 2024 11:05:32 +0100 Subject: [PATCH] Issue#520: add --user and --group to parseApplicationCriteriaArgs procedure (second attempt) --- tcl/mfcmd.tcl | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/tcl/mfcmd.tcl b/tcl/mfcmd.tcl index 0c1f5ad79..3f1d5ae61 100644 --- a/tcl/mfcmd.tcl +++ b/tcl/mfcmd.tcl @@ -251,7 +251,6 @@ proc __parseDateTimeArg {opt datetime} { # parse application criteria arguments and determine if command applies proc parseApplicationCriteriaArgs {aftbef nearsec args} { - set flag {} set otherargs {} # parse argument list @@ -279,7 +278,6 @@ proc parseApplicationCriteriaArgs {aftbef nearsec args} { } } --not-group - --not-user { - set flag 0 if {[getState is_win]} { knerror "Option '$arg' not supported on Windows platform" } else { @@ -287,7 +285,6 @@ proc parseApplicationCriteriaArgs {aftbef nearsec args} { } } --group - --user { - set flag 1 if {[getState is_win]} { knerror "Option '$arg' not supported on Windows platform" } else { @@ -324,29 +321,22 @@ proc parseApplicationCriteriaArgs {aftbef nearsec args} { set isafter [expr {[info exists after] && [getState clock_seconds] >=\ $after}] - # extract boolean expression according to used argument (driven by $flag) - if {$flag == 0} { - # are criteria met - set apply [expr {!$notuser && !$notgroup && ($isbefore || $isafter ||\ - (![info exists before] && ![info exists after]))}] - - # is end limit near ? - set isnearly [expr {!$apply && !$notuser && !$notgroup && [info exists\ - after] && !$isafter && [getState clock_seconds] >= ($after - $nearsec)}] - if {![info exists afterraw]} { - set afterraw {} - } - } else { - # are criteria met - set apply [expr {$user || $group && ($isbefore || $isafter ||\ - (![info exists before] && ![info exists after]))}] - - # is end limit near ? - set isnearly [expr {!$apply && $user || $group && [info exists\ - after] && !$isafter && [getState clock_seconds] >= ($after - $nearsec)}] - if {![info exists afterraw]} { - set afterraw {} - } + set user_or_group_target_defined [expr {[info exists user] || [info exists\ + group]}] + set user_or_group_targeted [expr {$user || $group}] + set user_or_group_excluded [expr {$notuser || $notgroup}] + set time_frame_defined [expr {[info exists before] || [info exists after]}] + set in_time_frame [expr {!$time_frame_defined || $isbefore || $isafter}] + + set apply [expr {$in_time_frame && ($user_or_group_targeted ||\ + (!$user_or_group_target_defined && !$user_or_group_excluded))}] + + # is end limit near ? + set isnearly [expr {!$apply && !$notuser && !$notgroup && $user && $group\ + [info exists after] && !$isafter &&\ + [getState clock_seconds] >= ($after - $nearsec)}] + if {![info exists afterraw]} { + set afterraw {} } return [list $apply $isnearly $afterraw $otherargs]