[Fix] use Solaris-compatible tail options.
Fixes #1148.
parent
8c8bf1204c
commit
78a008c3c7
12
nvm.sh
12
nvm.sh
|
@ -292,7 +292,7 @@ nvm_version() {
|
||||||
PATTERN="stable"
|
PATTERN="stable"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
VERSION="$(nvm_ls "$PATTERN" | command tail -n1)"
|
VERSION="$(nvm_ls "$PATTERN" | command tail -1)"
|
||||||
if [ -z "$VERSION" ] || [ "_$VERSION" = "_N/A" ]; then
|
if [ -z "$VERSION" ] || [ "_$VERSION" = "_N/A" ]; then
|
||||||
nvm_echo "N/A"
|
nvm_echo "N/A"
|
||||||
return 3;
|
return 3;
|
||||||
|
@ -308,14 +308,14 @@ nvm_remote_version() {
|
||||||
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
||||||
case "_$PATTERN" in
|
case "_$PATTERN" in
|
||||||
"_$(nvm_iojs_prefix)")
|
"_$(nvm_iojs_prefix)")
|
||||||
VERSION="$(nvm_ls_remote_iojs | command tail -n1)"
|
VERSION="$(nvm_ls_remote_iojs | command tail -1)"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
VERSION="$(nvm_ls_remote "$PATTERN")"
|
VERSION="$(nvm_ls_remote "$PATTERN")"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
VERSION="$(nvm_remote_versions "$PATTERN" | command tail -n1)"
|
VERSION="$(nvm_remote_versions "$PATTERN" | command tail -1)"
|
||||||
fi
|
fi
|
||||||
nvm_echo "$VERSION"
|
nvm_echo "$VERSION"
|
||||||
if [ "_$VERSION" = '_N/A' ]; then
|
if [ "_$VERSION" = '_N/A' ]; then
|
||||||
|
@ -845,7 +845,7 @@ nvm_ls_remote() {
|
||||||
local PATTERN
|
local PATTERN
|
||||||
PATTERN="$1"
|
PATTERN="$1"
|
||||||
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
if nvm_validate_implicit_alias "$PATTERN" 2> /dev/null ; then
|
||||||
PATTERN="$(nvm_ls_remote "$(nvm_print_implicit_alias remote "$PATTERN")" | command tail -n1)"
|
PATTERN="$(nvm_ls_remote "$(nvm_print_implicit_alias remote "$PATTERN")" | command tail -1)"
|
||||||
elif [ -n "$PATTERN" ]; then
|
elif [ -n "$PATTERN" ]; then
|
||||||
PATTERN="$(nvm_ensure_version_prefix "$PATTERN")"
|
PATTERN="$(nvm_ensure_version_prefix "$PATTERN")"
|
||||||
else
|
else
|
||||||
|
@ -1569,9 +1569,9 @@ nvm_npm_global_modules() {
|
||||||
local VERSION
|
local VERSION
|
||||||
VERSION="$1"
|
VERSION="$1"
|
||||||
if [ "_$VERSION" = "_system" ]; then
|
if [ "_$VERSION" = "_system" ]; then
|
||||||
NPMLIST=$(nvm use system > /dev/null && npm list -g --depth=0 2> /dev/null | command tail -n +2)
|
NPMLIST=$(nvm use system > /dev/null && npm list -g --depth=0 2> /dev/null | command sed 1,1d)
|
||||||
else
|
else
|
||||||
NPMLIST=$(nvm use "$VERSION" > /dev/null && npm list -g --depth=0 2> /dev/null | command tail -n +2)
|
NPMLIST=$(nvm use "$VERSION" > /dev/null && npm list -g --depth=0 2> /dev/null | command sed 1,1d)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local INSTALLS
|
local INSTALLS
|
||||||
|
|
|
@ -7,16 +7,16 @@ die () { echo $@ ; exit 1; }
|
||||||
nvm_has_system_node() { return 0; }
|
nvm_has_system_node() { return 0; }
|
||||||
nvm_print_npm_version() { return ' (npm v1.2.3)'; }
|
nvm_print_npm_version() { return ' (npm v1.2.3)'; }
|
||||||
EXPECTED_OUTPUT="Now using system version of node: $(node -v)$(nvm_print_npm_version)"
|
EXPECTED_OUTPUT="Now using system version of node: $(node -v)$(nvm_print_npm_version)"
|
||||||
[ "$(nvm use system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Could not use system version of node"
|
[ "$(nvm use system 2>&1 | tail -1)" = "${EXPECTED_OUTPUT}" ] || die "Could not use system version of node"
|
||||||
EXPECTED_OUTPUT=""
|
EXPECTED_OUTPUT=""
|
||||||
[ "$(nvm use --silent system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Could not use system version of node or --silent was not silent"
|
[ "$(nvm use --silent system 2>&1 | tail -1)" = "${EXPECTED_OUTPUT}" ] || die "Could not use system version of node or --silent was not silent"
|
||||||
|
|
||||||
nvm_has_system_node() { return 1; }
|
nvm_has_system_node() { return 1; }
|
||||||
nvm_print_npm_version() { return ''; }
|
nvm_print_npm_version() { return ''; }
|
||||||
EXPECTED_OUTPUT="System version of node not found."
|
EXPECTED_OUTPUT="System version of node not found."
|
||||||
[ "$(nvm use system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Did not report error, system node not found"
|
[ "$(nvm use system 2>&1 | tail -1)" = "${EXPECTED_OUTPUT}" ] || die "Did not report error, system node not found"
|
||||||
nvm use system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found"
|
nvm use system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found"
|
||||||
EXPECTED_OUTPUT=""
|
EXPECTED_OUTPUT=""
|
||||||
[ "$(nvm use --silent system 2>&1 | tail -n1)" = "$EXPECTED_OUTPUT" ] || die "Did not report error, system node not found or --silent was not silent"
|
[ "$(nvm use --silent system 2>&1 | tail -1)" = "${EXPECTED_OUTPUT}" ] || die "Did not report error, system node not found or --silent was not silent"
|
||||||
nvm use --silent system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found or --silent was not silent"
|
nvm use --silent system 2>&1 > /dev/null || [ $? -eq 127 ] || die "Did not return error code, system node not found or --silent was not silent"
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ die () { echo $@ ; exit 1; }
|
||||||
. ../../nvm.sh
|
. ../../nvm.sh
|
||||||
|
|
||||||
NVM_VERSION="v1"
|
NVM_VERSION="v1"
|
||||||
NVM_PREFIXED_TEST_VERSION="$(nvm ls-remote "$NVM_VERSION" | tail -n1 | sed 's/^[ ]*//;s/[ ]*$//')"
|
NVM_PREFIXED_TEST_VERSION="$(nvm ls-remote "$NVM_VERSION" | tail -1 | sed 's/^[ ]*//;s/[ ]*$//')"
|
||||||
NVM_TEST_VERSION="$(nvm_strip_iojs_prefix "$NVM_PREFIXED_TEST_VERSION")"
|
NVM_TEST_VERSION="$(nvm_strip_iojs_prefix "$NVM_PREFIXED_TEST_VERSION")"
|
||||||
|
|
||||||
# Remove the stuff we're clobbering.
|
# Remove the stuff we're clobbering.
|
||||||
|
|
Loading…
Reference in New Issue