aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2020-07-16 20:34:27 +0200
committerGravatar Christian Hesse <mail@eworm.de>2020-07-16 20:34:27 +0200
commit910641b6fa9548e0b06f64aad82082506b03c89e (patch)
treee761ed9038ab4ab856d09c0139dcd95fd7661f37 /global-functions
parent5859b0406ee11f07af2cfe97ab9e2a9a7c30ffa8 (diff)
global-functions: introduce $IfThenElse
Diffstat (limited to 'global-functions')
-rw-r--r--global-functions9
1 files changed, 9 insertions, 0 deletions
diff --git a/global-functions b/global-functions
index fe51031..e20017b 100644
--- a/global-functions
+++ b/global-functions
@@ -27,6 +27,7 @@
:global GetMacVendor;
:global GetRandomNumber;
:global GetRandomSha256;
+:global IfThenElse;
:global IPCalc;
:global LogPrintExit;
:global MailServerIsUp;
@@ -339,6 +340,14 @@
:return $FingerPrint;
}
+# mimic conditional/ternary operator (condition ? consequent : alternative)
+:set IfThenElse do={
+ :if ([ :tostr $1 ] = "true" || [ :tobool $1 ] = true) do={
+ :return $2;
+ }
+ :return $3;
+}
+
# calculate and print netmask, network, min host, max host and broadcast
:set IPCalc do={
:local Input [ :tostr $1 ];