[Tizen] Fix issue with return from non-sourced script if tools are already initialized
authorGleb Balykov <g.balykov@samsung.com>
Tue, 14 Jul 2020 15:19:04 +0000 (18:19 +0300)
committerAlexander Soldatov/AI Compiler Lab /SRR/Staff Engineer/Samsung Electronics <soldatov.a@samsung.com>
Thu, 23 Jul 2020 13:00:54 +0000 (16:00 +0300)
init-tools.sh

index 5ac2b44..5f0fb64 100755 (executable)
@@ -17,7 +17,13 @@ __BUILD_TOOLS_SEMAPHORE="$__TOOLRUNTIME_DIR/$__BUILD_TOOLS_PACKAGE_VERSION/init-
 
 if [ -e "$__BUILD_TOOLS_SEMAPHORE" ]; then
     echo "Tools are already initialized"
-    return #return instead of exit because this script is inlined in other scripts which we don't want to exit
+    if [ "$0" = "$BASH_SOURCE" ]; then
+        # not sourced
+        exit 0
+    else
+        # sourced
+        return #return instead of exit because this script is inlined in other scripts which we don't want to exit
+    fi
 fi
 
 if [ -e "$__TOOLRUNTIME_DIR" ]; then rm -rf -- "$__TOOLRUNTIME_DIR"; fi