zephyr-env.sh: Fixed sourcing the project environment file
In zsh the value of $0 depends on the FUNCTION_ARGZERO option which is set by default. FUNCTION_ARGZERO, when it is set, sets $0 temporarily to the name of the function/script when executing a shell function or sourcing a script. POSIX_ARGZERO option, when it is set, exposes the original value of $0 in spite of the current FUNCTION_ARGZERO setting. This patch allows to source the project environment file from both zsh and bash. It also removes the -z option from the basename command which is missing in OS X. Change-Id: I5a32404784d9064bf749fa58b4d73d4b56c908c2 Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
This commit is contained in:
parent
9055bfe58f
commit
3e3e297719
1 changed files with 18 additions and 1 deletions
|
@ -14,7 +14,24 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
if [ "X$(basename -z -- "$0")" "==" "Xzephyr-env.sh" ]; then
|
||||
# In zsh the value of $0 depends on the FUNCTION_ARGZERO option which is
|
||||
# set by default. FUNCTION_ARGZERO, when it is set, sets $0 temporarily
|
||||
# to the name of the function/script when executing a shell function or
|
||||
# sourcing a script. POSIX_ARGZERO option, when it is set, exposes the
|
||||
# original value of $0 in spite of the current FUNCTION_ARGZERO setting.
|
||||
if [ -n "$ZSH_VERSION" ]; then
|
||||
if [ $options[posixargzero] != "on" ]; then
|
||||
setopt posixargzero
|
||||
NAME=$(basename -- "$0")
|
||||
setopt posixargzero
|
||||
else
|
||||
NAME=$(basename -- "$0")
|
||||
fi
|
||||
else
|
||||
NAME=$(basename -- "$0")
|
||||
fi
|
||||
|
||||
if [ "X$NAME" "==" "Xzephyr-env.sh" ]; then
|
||||
echo "Source this file (do NOT execute it!) to set the Zephyr Kernel environment."
|
||||
exit
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue