package/environment-setup/environment-setup: add zsh
PATCH 1/1 package/environment-setup/environment-setup: add zsh
environment-setup used BASH_SOURCE which is bash specific and empty variable for zsh (and other shell's).
Use $0 which should be work across multiple shells(tcsh, dash, zsh) It won't work if other script is sourcing environment-setup.
--- package/environment-setup/environment-setup | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
package/environment-setup/environment-setup +5 -1
@@ -16,4 +16,8 @@ Some tips: * To build CMake-based projects, use the "cmake" alias EOF -SDK_PATH=$(dirname $(realpath "${BASH_SOURCE[0]}")) +if [ x"${BASH_SOURCE}" != x"" ]; then + SDK_PATH=$(dirname $(realpath "${BASH_SOURCE[0]}")) +else + SDK_PATH=$(dirname $(realpath $0)) +fi
Signature · 6 lines
2.33.0 _______________________________________________ buildroot mailing list [email protected] http://lists.busybox.net/mailman/listinfo/buildroot
Quoted 4 lines · Krzysztof Kanas
environment-setup used
BASH_SOURCEwhich is bash specific and empty variable for zsh (and other shell's).
Use $0 which should be work across multipleshells(tcsh, dash, zsh)It won't work if other script is sourcing environment-setup.
The environment-setup is supposed to be source'd, so how is this ever going to
work?
I think the only viable solution is to require an argument if shell is not bash.
Regards,
Arnout
Quoted 12 lines
Signed-off-by Krzysztof Kanas <[email protected]>--- package/environment-setup/environment-setup | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)package/environment-setup/environment-setup +0
-0
package/environment-setup/environment-setup Some tips: · line 23
Quoted 9 lines
package/environment-setup/environment-setup +5
-1@@ -16,4 +16,8 @@ Some tips: * To build CMake-based projects, use the "cmake" alias EOF -SDK_PATH=$(dirname $(realpath "${BASH_SOURCE[0]}")) +if [ x"${BASH_SOURCE}" != x"" ]; then + SDK_PATH=$(dirname $(realpath "${BASH_SOURCE[0]}")) +else + SDK_PATH=$(dirname $(realpath $0)) +fi
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
Quoted 10 lines · Arnout Vandecappelle
Quoted 4 lines · Krzysztof Kanas
environment-setup used
BASH_SOURCEwhich is bash specific and empty variable for zsh (and other shell's).
Use $0 which should be work across multipleshells(tcsh, dash, zsh)It won't work if other script is sourcing environment-setup.The environment-setup is supposed to be source'd, so how is this ever going to
work?
This script will work when sourced interactively from bash shell due the test for ${BASH_SOURCE} so this behavior is not changed.
What I meant by this paragraph was how different shell's set $0 augment whether script is sourced interactively or sourced from another script, e.g:
cat > foo.sh
source environment-setup
^D
But I missed case when environment-setup is sourced from another directory, lucky this works in zsh case, but not in case of dash, ksh. So the fix would be applicable to zsh only (actually my main purpose for the patch).
Quoted 2 lines
I think the only viable solution is to require an argument if shell is not bash.
So you are thinking of
if [ $SHELL != bash ] ; then ?
I don't know if that will be easy/portable to do b/c running,
zsh
bash
env|grep SHELL
SHELL=/bin/zsh
XTERM_SHELL=/bin/zsh
Quoted 17 lines
Regards,
ArnoutQuoted 13 lines
Signed-off-by Krzysztof Kanas <[email protected]>--- package/environment-setup/environment-setup | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)package/environment-setup/environment-setup +0
-0@@ -16,4 +16,8 @@ Some tips: * To build CMake-based projects, use the "cmake" alias
Quoted 8 lines
package/environment-setup/environment-setup Some tips: · line 23
Quoted 8 lines
package/environment-setup/environment-setup +5
-1EOF -SDK_PATH=$(dirname $(realpath "${BASH_SOURCE[0]}")) +if [ x"${BASH_SOURCE}" != x"" ]; then + SDK_PATH=$(dirname $(realpath "${BASH_SOURCE[0]}")) +else + SDK_PATH=$(dirname $(realpath $0)) +fi
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
Quoted 28 lines · Krzysztof Kanas
Quoted 10 lines · Arnout Vandecappelle
Quoted 4 lines · Krzysztof Kanas
environment-setup used
BASH_SOURCEwhich is bash specific and empty variable for zsh (and other shell's).
Use $0 which should be work across multipleshells(tcsh, dash, zsh)It won't work if other script is sourcing environment-setup.The environment-setup is supposed to be source'd, so how is this ever going to work?
This script will work when sourced interactively from bash shell due the test for ${BASH_SOURCE} so this behavior is not changed.
What I meant by this paragraph was how different shell's set $0 augment whether script is sourced interactively or sourced from another script, e.g:
cat >foo.sh
source environment-setup
^DBut I missed case when environment-setup is sourced from another directory, lucky this works in zsh case, but not in case of dash, ksh.
So the fix would be applicable to zsh only (actually my main purpose for the patch).Quoted 1 line
Quoted 4 lines
Quoted 2 lines
I think the only viable solution is to require an argument if shell is not bash.
So you are thinking of
if [ $SHELL != bash ] ; then ?
I was thinking of your if [ x"${BASH_SOURCE}" != x"" ]
Regards,
Arnout
Quoted 18 lines
I don't know if that will be easy/portable to do b/c running,
zsh
bash
env|grep SHELL
SHELL=/bin/zsh
XTERM_SHELL=/bin/zshQuoted 10 lines
Regards,
ArnoutQuoted 6 lines
Signed-off-by Krzysztof Kanas <[email protected]>---
package/environment-setup/environment-setup | 6 +++++-1 file changed, 5 insertions(+), 1 deletion(-)
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
package/environment-setup/environment-setup +0
-0@@ -16,4 +16,8 @@ Some tips: * To build CMake-based projects, use the "cmake" aliasQuoted 8 lines
package/environment-setup/environment-setup Some tips: · line 23
Quoted 8 lines
EOF
package/environment-setup/environment-setup +5
-1-SDK_PATH=$(dirname $(realpath "${BASH_SOURCE[0]}")) +if [ x"${BASH_SOURCE}" != x"" ]; then + SDK_PATH=$(dirname $(realpath "${BASH_SOURCE[0]}")) +else + SDK_PATH=$(dirname $(realpath $0)) +fi
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
Quoted 31 lines · Arnout Vandecappelle
Quoted 28 lines · Krzysztof Kanas
Quoted 10 lines · Arnout Vandecappelle
Quoted 4 lines · Krzysztof Kanas
environment-setup used
BASH_SOURCEwhich is bash specific and empty variable for zsh (and other shell's).
Use $0 which should be work across multipleshells(tcsh, dash, zsh)It won't work if other script is sourcing environment-setup.The environment-setup is supposed to be source'd, so how is this ever going to
work?This script will work when sourced interactively from bash shell due the test for ${BASH_SOURCE} so this behavior is not changed.
What I meant by this paragraph was how different shell's set $0 augment whether script is sourced interactively or sourced from another script, e.g:
cat >foo.sh
source environment-setup
^DBut I missed case when environment-setup is sourced from another directory, lucky this works in zsh case, but not in case of dash, ksh.
So the fix would be applicable to zsh only (actually my main purpose for the patch).Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
I think the only viable solution is to require an argument if shell is not
bash.So you are thinking of
if [ $SHELL != bash ] ; then ?I was thinking of your if [ x"${BASH_SOURCE}" != x"" ]
So what about:
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
fi
This should work for bash as previously add zsh support, but won't work for dash (as it didn't work previously ), but will give clearer error indication.
Quoted 22 lines
Regards,
ArnoutQuoted 18 lines
I don't know if that will be easy/portable to do b/c running,
zsh
bash
env|grep SHELL
SHELL=/bin/zsh
XTERM_SHELL=/bin/zshQuoted 10 lines
Regards,
ArnoutQuoted 6 lines
Signed-off-by Krzysztof Kanas <[email protected]>--- package/environment-setup/environment-setup | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
package/environment-setup/environment-setup +0
-0@@ -16,4 +16,8 @@ Some tips: * To build CMake-based projects, use the "cmake" aliasQuoted 8 lines
Quoted 8 lines
package/environment-setup/environment-setup Some tips:
Quoted 8 lines
package/environment-setup/environment-setup +5
-1EOF -SDK_PATH=$(dirname $(realpath "${BASH_SOURCE[0]}")) +if [ x"${BASH_SOURCE}" != x"" ]; then + SDK_PATH=$(dirname $(realpath "${BASH_SOURCE[0]}")) +else + SDK_PATH=$(dirname $(realpath $0)) +fi
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 21 lines · Krzysztof Kanas
environment-setup used
BASH_SOURCEwhich 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 <[email protected]>---
Changes in v2:
- fix shell detection logic
- change commit comment--- package/environment-setup/environment-setup | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)package/environment-setup/environment-setup +0
-0
package/environment-setup/environment-setup Some tips: · line 24
Quoted 10 lines
package/environment-setup/environment-setup +6
-1@@ -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
package/environment-setup/environment-setup Some tips: · line 23
Quoted 2 lines
package/environment-setup/environment-setup +1
-0+fi
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Krzysztof" == Krzysztof Kanas <[email protected]> writes:
environment-setup used
BASH_SOURCEwhich 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.
Quoted 6 lines
Signed-off-by Krzysztof Kanas <[email protected]>---
Changes in v2:
- fix shell detection logic
- change commit comment
Committed to 2021.02.x, 2021.05.x and 2021.08.x, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot