zephyr-env.sh: Set correctly $ZEPHYR_BASE in zsh

Sourcing project environment file failed to set correctly
$ZEPHYR_BASE in zsh if it was sourced from another directory
(e.g. home directory). This patch fixes this issue.

It was tested on zsh, bash and sh on Linux.
It needs to be tested on OS X.

Change-Id: Idfb11c6a3109042a9f578f38b3849d9cf9c31f95
Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
This commit is contained in:
Yannis Damigos 2016-03-03 12:04:25 +02:00 committed by Gerrit Code Review
commit ea3b5d356c

View file

@ -20,6 +20,7 @@
# sourcing a script. POSIX_ARGZERO option, when it is set, exposes the # sourcing a script. POSIX_ARGZERO option, when it is set, exposes the
# original value of $0 in spite of the current FUNCTION_ARGZERO setting. # original value of $0 in spite of the current FUNCTION_ARGZERO setting.
if [ -n "$ZSH_VERSION" ]; then if [ -n "$ZSH_VERSION" ]; then
DIR="${(%):-%N}"
if [ $options[posixargzero] != "on" ]; then if [ $options[posixargzero] != "on" ]; then
setopt posixargzero setopt posixargzero
NAME=$(basename -- "$0") NAME=$(basename -- "$0")
@ -28,6 +29,7 @@ if [ -n "$ZSH_VERSION" ]; then
NAME=$(basename -- "$0") NAME=$(basename -- "$0")
fi fi
else else
DIR="${BASH_SOURCE[0]}"
NAME=$(basename -- "$0") NAME=$(basename -- "$0")
fi fi
@ -43,7 +45,7 @@ fi
uname | grep -q MINGW && MINGW_OPT="-W" uname | grep -q MINGW && MINGW_OPT="-W"
# identify OS source tree root directory # identify OS source tree root directory
export ZEPHYR_BASE=$( builtin cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ${MINGW_OPT}) export ZEPHYR_BASE=$( builtin cd "$( dirname "$DIR" )" && pwd ${MINGW_OPT})
scripts_path=${ZEPHYR_BASE}/scripts scripts_path=${ZEPHYR_BASE}/scripts
echo "${PATH}" | grep -q "${scripts_path}" echo "${PATH}" | grep -q "${scripts_path}"