[Buildroot] [git commit branch/2021.05.x] package/environment-setup/environment-setup: add zsh

Peter Korsgaard peter at korsgaard.com
Mon Sep 13 13:37:26 UTC 2021


commit: https://git.buildroot.net/buildroot/commit/?id=79b4de9f271d43ed57125033cf8e43b4d2d22bbd
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/2021.05.x

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 at fastmail.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout at mind.be>
(cherry picked from commit 65cee90cc3cec4da11987370ea2de35d32f046b5)
Signed-off-by: Peter Korsgaard <peter at korsgaard.com>
---
 package/environment-setup/environment-setup | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/package/environment-setup/environment-setup b/package/environment-setup/environment-setup
index e9bc36fdd0..84a9843c24 100644
--- a/package/environment-setup/environment-setup
+++ b/package/environment-setup/environment-setup
@@ -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


More information about the buildroot mailing list