Skip to content

[Robustness] handle an overridden type #2356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ nvm_grep() {
}

nvm_has() {
type "${1-}" >/dev/null 2>&1
command type "${1-}" >/dev/null 2>&1
}

nvm_has_non_aliased() {
Expand All @@ -61,18 +61,18 @@ nvm_command_info() {
local COMMAND
local INFO
COMMAND="${1}"
if type "${COMMAND}" | nvm_grep -q hashed; then
INFO="$(type "${COMMAND}" | command sed -E 's/\(|\)//g' | command awk '{print $4}')"
elif type "${COMMAND}" | nvm_grep -q aliased; then
if command type "${COMMAND}" | nvm_grep -q hashed; then
INFO="$(command type "${COMMAND}" | command sed -E 's/\(|\)//g' | command awk '{print $4}')"
elif command type "${COMMAND}" | nvm_grep -q aliased; then
# shellcheck disable=SC2230
INFO="$(which "${COMMAND}") ($(type "${COMMAND}" | command awk '{ $1=$2=$3=$4="" ;print }' | command sed -e 's/^\ *//g' -Ee "s/\`|'//g"))"
elif type "${COMMAND}" | nvm_grep -q "^${COMMAND} is an alias for"; then
INFO="$(which "${COMMAND}") ($(command type "${COMMAND}" | command awk '{ $1=$2=$3=$4="" ;print }' | command sed -e 's/^\ *//g' -Ee "s/\`|'//g"))"
elif command type "${COMMAND}" | nvm_grep -q "^${COMMAND} is an alias for"; then
# shellcheck disable=SC2230
INFO="$(which "${COMMAND}") ($(type "${COMMAND}" | command awk '{ $1=$2=$3=$4=$5="" ;print }' | command sed 's/^\ *//g'))"
elif type "${COMMAND}" | nvm_grep -q "^${COMMAND} is \\/"; then
INFO="$(type "${COMMAND}" | command awk '{print $3}')"
INFO="$(which "${COMMAND}") ($(command type "${COMMAND}" | command awk '{ $1=$2=$3=$4=$5="" ;print }' | command sed 's/^\ *//g'))"
elif command type "${COMMAND}" | nvm_grep -q "^${COMMAND} is \\/"; then
INFO="$(command type "${COMMAND}" | command awk '{print $3}')"
else
INFO="$(type "${COMMAND}")"
INFO="$(command type "${COMMAND}")"
fi
nvm_echo "${INFO}"
}
Expand Down