aboutsummaryrefslogtreecommitdiffstats
path: root/global-functions
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2019-12-03 21:46:04 +0100
committerGravatar Christian Hesse <mail@eworm.de>2019-12-03 23:45:55 +0100
commitebd5ff9bfecf8a843eb7ed87d10b2bacc8518ca6 (patch)
treefe9478266e406e1253120784e33271fcbb9f907a /global-functions
parentbccdb47fdedf5cccd779fd54766db05dfd1741ab (diff)
global-functions: introduce $ScriptFromTerminal
Checking whether or not started from terminal is tricky... We have to find the job for the script, find its top most parent and get its type.
Diffstat (limited to 'global-functions')
-rw-r--r--global-functions18
1 files changed, 18 insertions, 0 deletions
diff --git a/global-functions b/global-functions
index 218262b..2bff9cc 100644
--- a/global-functions
+++ b/global-functions
@@ -243,6 +243,24 @@
}
}
+# check if script is run from terminal
+:global ScriptFromTerminal do={
+ :local Script [ :tostr $1 ];
+
+ :foreach Job in=[ / system script job find where script=$Script ] do={
+ :set Job [ / system script job get $Job ];
+ :while ([ :typeof ($Job->"parent") ] = "id") do={
+ :set Job [ / system script job get [ find where .id=($Job->"parent") ] ];
+ }
+ :if (($Job->"type") = "login") do={
+ :log debug ("Script " . $Script . " started from terminal.");
+ :return true;
+ }
+ }
+
+ :return false;
+}
+
# wait for file to be available
:global WaitForFile do={
:global CleanFilePath;