package/environment-setup/environment-setup: add zsh
authorKrzysztof Kanas <kkanas@fastmail.com>
Thu, 2 Sep 2021 11:28:50 +0000 (13:28 +0200)
committerArnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Sat, 11 Sep 2021 14:58:28 +0000 (16:58 +0200)
environment-setup uses BASH_SOURCE which is bash specific. For other
shells, this variable is empty, leading to an error message and empty
SDK_PATH.
Zsh Uses $0. Unfortunately POSIX is not specifying how exactly $0
should behave when in sourced (or using special dot utility). So other
shell support have to be implemented in different manner.

Signed-off-by: Krzysztof Kanas <kkanas@fastmail.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
package/environment-setup/environment-setup

index e9bc36fdd0933d9d75f03b59ececc7361d5a0fa5..84a9843c2434c4ea5d75147e111fd65202191315 100644 (file)
@@ -16,4 +16,10 @@ Some tips:
 * To build CMake-based projects, use the "cmake" alias
 
 EOF
-SDK_PATH=$(dirname $(realpath "${BASH_SOURCE[0]}"))
+if [ x"$BASH_VERSION" != x"" ] ; then
+       SDK_PATH=$(dirname $(realpath "${BASH_SOURCE[0]}"))
+elif [ x"$ZSH_VERSION" != x"" ] ; then
+       SDK_PATH=$(dirname $(realpath $0))
+else
+       echo "unsupported shell"
+fi