aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2020-02-03 21:29:21 +0100
committerGravatar Christian Hesse <mail@eworm.de>2020-02-03 21:29:21 +0100
commit03af7d6d9c64cc57d1d0e3280e4ed1a6308e6448 (patch)
treea459d72e4c1b8a670ca380b1589058656b65006d /global-functions
parent0c705d5311355f182dfb3ba36c9e533c2193a980 (diff)
global-functions: $CharacterReplace: do not limit string length
I've tried something like this to update a device: / system script set source=[ $CharacterReplace [ get global-config-overlay source ] "GlobalConfigVersion 10" "GlobalConfigVersion 11" ] global-config-overlay; This broke with global-config-overlay longer than 999 characters. So makes sure there is no limit for string length.
Diffstat (limited to 'global-functions')
-rw-r--r--global-functions3
1 files changed, 1 insertions, 2 deletions
diff --git a/global-functions b/global-functions
index 05b5093..15cba35 100644
--- a/global-functions
+++ b/global-functions
@@ -64,7 +64,6 @@
:local String [ :tostr $1 ];
:local ReplaceFrom [ :tostr $2 ];
:local ReplaceWith [ :tostr $3 ];
- :local Len [ :len $ReplaceFrom ];
:local Return "";
:if ($ReplaceFrom = "") do={
@@ -74,7 +73,7 @@
:while ([ :typeof [ :find $String $ReplaceFrom ] ] != "nil") do={
:local Pos [ :find $String $ReplaceFrom ];
:set Return ($Return . [ :pick $String 0 $Pos ] . $ReplaceWith);
- :set String [ :pick $String ($Pos + $Len) 999 ];
+ :set String [ :pick $String ($Pos + [ :len $ReplaceFrom ]) [ :len $String ] ];
}
:return ($Return . $String);