Skip to content

Commit

Permalink
[Fix] bypass aliased cd in a few places.
Browse files Browse the repository at this point in the history
Fixes #1284.
  • Loading branch information
ljharb committed Nov 3, 2016
1 parent a458ccb commit 942e9ab
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ nvm_echo() {
}
}

nvm_cd() {
# shellcheck disable=SC1001,SC2164
\cd "$@"
}

nvm_err() {
>&2 nvm_echo "$@"
}
Expand Down Expand Up @@ -115,7 +120,7 @@ if [ -z "${NVM_DIR-}" ]; then
NVM_SCRIPT_SOURCE="${BASH_SOURCE[0]}"
fi
# shellcheck disable=SC1001
NVM_DIR="$(cd ${NVM_CD_FLAGS} "$(dirname "${NVM_SCRIPT_SOURCE:-$0}")" > /dev/null && \pwd)"
NVM_DIR="$(nvm_cd ${NVM_CD_FLAGS} "$(dirname "${NVM_SCRIPT_SOURCE:-$0}")" > /dev/null && \pwd)"
export NVM_DIR
fi
unset NVM_SCRIPT_SOURCE 2> /dev/null
Expand Down Expand Up @@ -1845,7 +1850,7 @@ nvm_install_source() {
command mkdir -p "${TMPDIR}" && \
command tar -x${tar_compression_flag}f "${TARBALL}" -C "${TMPDIR}" --strip-components 1 && \
VERSION_PATH="$(nvm_version_path "${PREFIXED_VERSION}")" && \
cd "${TMPDIR}" && \
nvm_cd "${TMPDIR}" && \
./configure --prefix="${VERSION_PATH}" $ADDITIONAL_PARAMETERS && \
$make -j "${NVM_MAKE_JOBS}" ${MAKE_CXX-} && \
command rm -f "${VERSION_PATH}" 2>/dev/null && \
Expand Down Expand Up @@ -3022,7 +3027,7 @@ nvm() {
for LINK in $LINKS; do
set +f; unset IFS # restore variable expansion
if [ -n "$LINK" ]; then
(cd "$LINK" && npm link)
(nvm_cd "$LINK" && npm link)
fi
done
set +f; unset IFS # restore variable expansion in case $LINKS was empty
Expand Down

0 comments on commit 942e9ab

Please sign in to comment.