Browse Source

[Fix] `nvm debug`: Fix sed syntax error in nvm_command_info()

Peter Dave Hello 7 years ago committed by Jordan Harband
parent
commit
d5dacdf80f
No known key found for this signature in database
GPG Key ID: 64A196AEE0916D55
  1. 2
      nvm.sh
  2. 8
      test/fast/Unit tests/nvm_command_info

2
nvm.sh

@ -48,7 +48,7 @@ nvm_command_info() { @@ -48,7 +48,7 @@ nvm_command_info() {
local INFO
COMMAND="${1}"
if type "${COMMAND}" | nvm_grep -q hashed; then
INFO="$(type "${COMMAND}" | command sed -E 's/\(|)//g' | command awk '{print $4}')"
INFO="$(type "${COMMAND}" | command sed -E 's/\(|\)//g' | command awk '{print $4}')"
elif type "${COMMAND}" | nvm_grep -q aliased; then
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

8
test/fast/Unit tests/nvm_command_info

@ -38,3 +38,11 @@ WGET_EXPECTED_INFO="$(type wget)" @@ -38,3 +38,11 @@ WGET_EXPECTED_INFO="$(type wget)"
[ "${WGET_COMMAND_INFO}" = "${WGET_EXPECTED_INFO}" ] || die "wget command info wrong(stage 3), expected: '${WGET_EXPECTED_INFO}', got '${WGET_COMMAND_INFO}'"
cleanup
# 4. nvm_command_info() should not have standard error
nvm_command_info ls 2>&1 >/dev/null | grep . && die "\`nvm_command_info ls\` should not return standard error message(stage 4)"
nvm_command_info rm 2>&1 >/dev/null | grep . && die "\`nvm_command_info rm\` should not return standard error message(stage 4)"
nvm_command_info git 2>&1 >/dev/null | grep . && die "\`nvm_command_info git\` should not return standard error message(stage 4)"
nvm_command_info grep 2>&1 >/dev/null | grep . && die "\`nvm_command_info grep\` should not return standard error message(stage 4)"
cleanup

Loading…
Cancel
Save