[Buildroot] [PATCH v2 1/1] package/environment-setup/environment-setup: add zsh

Arnout Vandecappelle arnout at mind.be
Sat Sep 11 14:53:11 UTC 2021



On 02/09/2021 13:28, Krzysztof Kanas wrote:
> environment-setup used BASH_SOURCE which is bash specific and empty
> variable for zsh (and other shell's).
> 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>
> 
> ---
> Changes in v2:
> 	- fix shell detection logic
> 	- change commit comment
> ---
>  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 e9bc36fdd093..6716c19a577a 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 unsuported shell

 I fixed the spelling mistake, added quotes around it, and applied to master,
thanks.

 Regards,
 Arnout

> +fi
> 



More information about the buildroot mailing list