aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2022-07-05 12:29:29 +0200
committerGravatar Christian Hesse <mail@eworm.de>2022-07-05 12:43:57 +0200
commiteda75f0bbc400950d0d98ad7456096deb2a8e755 (patch)
tree9ceef3584b02c2f7d7659346e552b807a52e68d4
parentb0992da03d0b70d569c4dfe289226f9494348a7c (diff)
global-functions: introduce function $PrettyPrint
... to add trailing carriage return when printing to terminal: [admin@MikroTik] > $PrettyPrint [ $DeviceInfo ] Hostname: MikroTik Board name: hAP ac^2 Architecture: arm Model: RouterBOARD D52G-5HacD2HnD-TC Serial number: 8A2A09A221A1 RouterOS: Channel: testing Installed: 7.4rc1 RouterOS-Scripts: Current: 81
-rw-r--r--global-functions10
1 files changed, 10 insertions, 0 deletions
diff --git a/global-functions b/global-functions
index 3a2497e..daa6526 100644
--- a/global-functions
+++ b/global-functions
@@ -40,6 +40,7 @@
:global MkDir;
:global NotificationFunctions;
:global ParseKeyValueStore;
+:global PrettyPrint;
:global QuotedPrintable;
:global RandomDelay;
:global Read;
@@ -648,6 +649,15 @@
:return $Result;
}
+# print lines with trailing carriage return
+:set PrettyPrint do={
+ :local Input [ :tostr $1 ];
+
+ :global CharacterReplace;
+
+ :put [ $CharacterReplace $Input ("\n") ("\n\r") ];
+}
+
# convert string to quoted-printable
:global QuotedPrintable do={
:local Input [ :tostr $1 ];