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>
This commit is contained in:
Dimitrios Apostolou
2019-10-02 19:05:15 +02:00
parent d97d1af1ee
commit 869a9b3ae7

View File

@@ -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" ]
}