summaryrefslogtreecommitdiffstats
path: root/coin/provisioning/common
diff options
context:
space:
mode:
authorDimitrios Apostolou <jimis@qt.io>2019-10-02 19:05:15 +0200
committerDimitrios Apostolou <jimis@qt.io>2019-10-08 08:26:34 +0200
commit869a9b3ae7135158247113921c2dfc6cbe7ad6ce (patch)
tree99081791fdd139c5e209a80d59cda1f72215441b /coin/provisioning/common
parentd97d1af1eeb4185e9ae6ce73c3184e5e9834902b (diff)
Fix shell function is_script_executed
It used to return error when tested inside a login shell, because $0 is "-bash" and `basename` was trying to interpret -b as an option. Change-Id: I5faa2dc01e50c7d5bcfc0ab1fcfd910b2538afc2 Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
Diffstat (limited to 'coin/provisioning/common')
-rw-r--r--coin/provisioning/common/unix/common.sourced.sh4
1 files changed, 3 insertions, 1 deletions
diff --git a/coin/provisioning/common/unix/common.sourced.sh b/coin/provisioning/common/unix/common.sourced.sh
index 7fb267a6..aca5dd04 100644
--- a/coin/provisioning/common/unix/common.sourced.sh
+++ b/coin/provisioning/common/unix/common.sourced.sh
@@ -65,8 +65,10 @@ fatal () {
fi
}
+# Takes one argument which should be the filename of this script. Returns true
+# if the script is being sourced, false if the script is being executed.
is_script_executed () {
- [ x"$(basename "$0")" = x"$1" ]
+ [ x"$(basename $(echo "$0" | sed s/^-//))" = x"$1" ]
}