sms-action: early exit with :exit

This commit is contained in:
Christian Hesse 2026-01-19 15:24:32 +01:00
parent c8fad93ef3
commit c0ca1f8511
2 changed files with 4 additions and 6 deletions

View file

@ -3,12 +3,11 @@
# Copyright (c) 2018-2026 Christian Hesse <mail@eworm.de>
# https://rsc.eworm.de/COPYING.md
#
# requires RouterOS, version=7.19
# requires RouterOS, version=7.22
#
# run action on received SMS
# https://rsc.eworm.de/doc/sms-action.md
:local ExitOK false;
:onerror Err {
:global GlobalConfigReady; :global GlobalFunctionsReady;
:retry { :if ($GlobalConfigReady != true || $GlobalFunctionsReady != true) \
@ -24,8 +23,7 @@
:if ([ :typeof $Action ] = "nothing") do={
$LogPrint error $ScriptName ("This script is supposed to run from SMS hook with action=...");
:set ExitOK true;
:error false;
:exit;
}
:local Code ($SmsAction->$Action);
@ -37,5 +35,5 @@
$LogPrint warning $ScriptName ("The code for action '" . $Action . "' failed syntax validation!");
}
} do={
:global ExitError; $ExitError $ExitOK [ :jobname ] $Err;
:global ExitOnError; $ExitOnError [ :jobname ] $Err;
}