[shellcheck] double-quote vars in more places
parent
84aad508f7
commit
e7e28f436e
90
nvm.sh
90
nvm.sh
|
@ -33,7 +33,7 @@ nvm_get_latest() {
|
|||
>&2 echo "http://latest.nvm.sh did not redirect to the latest release on Github"
|
||||
return 2
|
||||
else
|
||||
echo "$NVM_LATEST_URL" | command awk -F'/' '{print $NF}'
|
||||
echo "$NVM_LATEST_URL" | command awk -F '/' '{print $NF}'
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ if [ -z "$NVM_DIR" ]; then
|
|||
if [ -n "$BASH_SOURCE" ]; then
|
||||
NVM_SCRIPT_SOURCE="${BASH_SOURCE[0]}"
|
||||
fi
|
||||
NVM_DIR="$(cd $NVM_CD_FLAGS $(dirname "${NVM_SCRIPT_SOURCE:-$0}") > /dev/null && \pwd)"
|
||||
NVM_DIR="$(cd $NVM_CD_FLAGS "$(dirname "${NVM_SCRIPT_SOURCE:-$0}")" > /dev/null && \pwd)"
|
||||
export NVM_DIR
|
||||
fi
|
||||
unset NVM_SCRIPT_SOURCE 2> /dev/null
|
||||
|
@ -147,18 +147,18 @@ nvm_rc_version() {
|
|||
|
||||
nvm_version_greater() {
|
||||
local LHS
|
||||
LHS=$(nvm_normalize_version "$1")
|
||||
LHS="$(nvm_normalize_version "$1")"
|
||||
local RHS
|
||||
RHS=$(nvm_normalize_version "$2")
|
||||
[ $LHS -gt $RHS ];
|
||||
RHS="$(nvm_normalize_version "$2")"
|
||||
[ "$LHS" -gt "$RHS" ];
|
||||
}
|
||||
|
||||
nvm_version_greater_than_or_equal_to() {
|
||||
local LHS
|
||||
LHS=$(nvm_normalize_version "$1")
|
||||
LHS="$(nvm_normalize_version "$1")"
|
||||
local RHS
|
||||
RHS=$(nvm_normalize_version "$2")
|
||||
[ $LHS -ge $RHS ];
|
||||
RHS="$(nvm_normalize_version "$2")"
|
||||
[ "$LHS" -ge "$RHS" ];
|
||||
}
|
||||
|
||||
nvm_version_dir() {
|
||||
|
@ -381,7 +381,7 @@ nvm_binary_available() {
|
|||
# binaries started with node 0.8.6
|
||||
local FIRST_VERSION_WITH_BINARY
|
||||
FIRST_VERSION_WITH_BINARY="0.8.6"
|
||||
nvm_version_greater_than_or_equal_to "$(nvm_strip_iojs_prefix $1)" "$FIRST_VERSION_WITH_BINARY"
|
||||
nvm_version_greater_than_or_equal_to "$(nvm_strip_iojs_prefix "$1")" "$FIRST_VERSION_WITH_BINARY"
|
||||
}
|
||||
|
||||
nvm_alias() {
|
||||
|
@ -556,7 +556,7 @@ nvm_ls() {
|
|||
if nvm_resolve_local_alias "$PATTERN"; then
|
||||
return
|
||||
fi
|
||||
PATTERN=$(nvm_ensure_version_prefix $PATTERN)
|
||||
PATTERN="$(nvm_ensure_version_prefix "$PATTERN")"
|
||||
;;
|
||||
esac
|
||||
if [ "_$PATTERN" = "_N/A" ]; then
|
||||
|
@ -654,7 +654,7 @@ nvm_ls() {
|
|||
)"
|
||||
fi
|
||||
|
||||
if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then
|
||||
if [ "$ZHS_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then
|
||||
unsetopt shwordsplit
|
||||
fi
|
||||
fi
|
||||
|
@ -717,7 +717,7 @@ nvm_ls_remote_iojs_org() {
|
|||
PATTERN="$3"
|
||||
local VERSIONS
|
||||
if [ -n "$PATTERN" ]; then
|
||||
PATTERN="$(nvm_ensure_version_prefix $(nvm_strip_iojs_prefix "$PATTERN"))"
|
||||
PATTERN="$(nvm_ensure_version_prefix "$(nvm_strip_iojs_prefix "$PATTERN")")"
|
||||
else
|
||||
PATTERN=".*"
|
||||
fi
|
||||
|
@ -774,7 +774,7 @@ nvm_print_versions() {
|
|||
else
|
||||
FORMAT='%15s'
|
||||
fi
|
||||
command printf "$FORMAT\n" $VERSION
|
||||
command printf "$FORMAT\n" "$VERSION"
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -821,7 +821,7 @@ nvm_print_implicit_alias() {
|
|||
NVM_COMMAND="nvm_ls_remote_iojs"
|
||||
NVM_ADD_PREFIX_COMMAND="nvm_add_iojs_prefix"
|
||||
if [ "_$1" = "_local" ]; then
|
||||
NVM_COMMAND="nvm_ls "$NVM_IMPLICIT""
|
||||
NVM_COMMAND="nvm_ls $NVM_IMPLICIT"
|
||||
fi
|
||||
|
||||
ZHS_HAS_SHWORDSPLIT_UNSET=1
|
||||
|
@ -835,10 +835,10 @@ nvm_print_implicit_alias() {
|
|||
NVM_IOJS_VERSION="$($NVM_COMMAND)"
|
||||
EXIT_CODE="$?"
|
||||
if [ "_$EXIT_CODE" = "_0" ]; then
|
||||
NVM_IOJS_VERSION="$(echo "$NVM_IOJS_VERSION" | sed "s/^"$NVM_IMPLICIT"-//" | command grep -e '^v' | command cut -c2- | command cut -d . -f 1,2 | uniq | command tail -1)"
|
||||
NVM_IOJS_VERSION="$(echo "$NVM_IOJS_VERSION" | sed "s/^$NVM_IMPLICIT-//" | command grep -e '^v' | command cut -c2- | command cut -d . -f 1,2 | uniq | command tail -1)"
|
||||
fi
|
||||
|
||||
if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then
|
||||
if [ "$ZHS_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then
|
||||
unsetopt shwordsplit
|
||||
fi
|
||||
|
||||
|
@ -867,7 +867,7 @@ nvm_print_implicit_alias() {
|
|||
|
||||
LAST_TWO=$($NVM_COMMAND | command grep -e '^v' | command cut -c2- | command cut -d . -f 1,2 | uniq)
|
||||
|
||||
if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then
|
||||
if [ "$ZHS_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then
|
||||
unsetopt shwordsplit
|
||||
fi
|
||||
;;
|
||||
|
@ -889,21 +889,21 @@ nvm_print_implicit_alias() {
|
|||
STABLE="$MINOR"
|
||||
else
|
||||
MOD=$(expr "$NORMALIZED_VERSION" \/ 1000000 \% 2)
|
||||
if [ $MOD -eq 0 ]; then
|
||||
if [ "$MOD" -eq 0 ]; then
|
||||
STABLE="$MINOR"
|
||||
elif [ $MOD -eq 1 ]; then
|
||||
elif [ "$MOD" -eq 1 ]; then
|
||||
UNSTABLE="$MINOR"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then
|
||||
if [ "$ZHS_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then
|
||||
unsetopt shwordsplit
|
||||
fi
|
||||
|
||||
if [ "_$2" = "_stable" ]; then
|
||||
echo $STABLE
|
||||
elif [ "_$2" = "_unstable" ]; then
|
||||
echo $UNSTABLE
|
||||
if [ "_$2" = '_stable' ]; then
|
||||
echo "${STABLE}"
|
||||
elif [ "_$2" = '_unstable' ]; then
|
||||
echo "${UNSTABLE}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -1013,7 +1013,7 @@ nvm_install_merged_node_binary() {
|
|||
if [ -n "$NVM_OS" ]; then
|
||||
t="$VERSION-$NVM_OS-$(nvm_get_arch)"
|
||||
url="$MIRROR/$VERSION/$NODE_PREFIX-${t}.tar.${compression}"
|
||||
sum="$(nvm_download -L -s $MIRROR/$VERSION/SHASUMS256.txt -o - | command grep $NODE_PREFIX-${t}.tar.${compression} | command awk '{print $1}')"
|
||||
sum="$(nvm_download -L -s "$MIRROR/$VERSION/SHASUMS256.txt" -o - | command grep "${NODE_PREFIX}-${t}.tar.${compression}" | command awk '{print $1}')"
|
||||
local tmpdir
|
||||
tmpdir="$NVM_DIR/bin/node-${t}"
|
||||
local tmptarball
|
||||
|
@ -1021,7 +1021,7 @@ nvm_install_merged_node_binary() {
|
|||
local NVM_INSTALL_ERRORED
|
||||
command mkdir -p "$tmpdir" && \
|
||||
echo "Downloading $url..." && \
|
||||
nvm_download -L -C - --progress-bar $url -o "$tmptarball" || \
|
||||
nvm_download -L -C - --progress-bar "$url" -o "$tmptarball" || \
|
||||
NVM_INSTALL_ERRORED=true
|
||||
if grep '404 Not Found' "$tmptarball" >/dev/null; then
|
||||
NVM_INSTALL_ERRORED=true
|
||||
|
@ -1030,7 +1030,7 @@ nvm_install_merged_node_binary() {
|
|||
if (
|
||||
[ "$NVM_INSTALL_ERRORED" != true ] && \
|
||||
echo "WARNING: checksums are currently disabled for node.js v4.0 and later" >&2 && \
|
||||
# nvm_checksum "$tmptarball" $sum && \
|
||||
# nvm_checksum "$tmptarball" "$sum" && \
|
||||
command tar -x${tar_compression_flag}f "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
||||
command rm -f "$tmptarball" && \
|
||||
command mkdir -p "$VERSION_PATH" && \
|
||||
|
@ -1088,7 +1088,7 @@ nvm_install_iojs_binary() {
|
|||
if nvm_binary_available "$VERSION"; then
|
||||
t="$VERSION-$NVM_OS-$(nvm_get_arch)"
|
||||
url="$MIRROR/$VERSION/$(nvm_iojs_prefix)-${t}.tar.${compression}"
|
||||
sum="$(nvm_download -L -s $MIRROR/$VERSION/SHASUMS256.txt -o - | command grep $(nvm_iojs_prefix)-${t}.tar.${compression} | command awk '{print $1}')"
|
||||
sum="$(nvm_download -L -s "$MIRROR/$VERSION/SHASUMS256.txt" -o - | command grep "$(nvm_iojs_prefix)-${t}.tar.${compression}" | command awk '{print $1}')"
|
||||
local tmpdir
|
||||
tmpdir="$NVM_DIR/bin/iojs-${t}"
|
||||
local tmptarball
|
||||
|
@ -1096,7 +1096,7 @@ nvm_install_iojs_binary() {
|
|||
local NVM_INSTALL_ERRORED
|
||||
command mkdir -p "$tmpdir" && \
|
||||
echo "Downloading $url..." && \
|
||||
nvm_download -L -C - --progress-bar $url -o "$tmptarball" || \
|
||||
nvm_download -L -C - --progress-bar "$url" -o "$tmptarball" || \
|
||||
NVM_INSTALL_ERRORED=true
|
||||
if grep '404 Not Found' "$tmptarball" >/dev/null; then
|
||||
NVM_INSTALL_ERRORED=true
|
||||
|
@ -1105,7 +1105,7 @@ nvm_install_iojs_binary() {
|
|||
if (
|
||||
[ "$NVM_INSTALL_ERRORED" != true ] && \
|
||||
echo "WARNING: checksums are currently disabled for io.js" >&2 && \
|
||||
# nvm_checksum "$tmptarball" $sum && \
|
||||
# nvm_checksum "$tmptarball" "$sum" && \
|
||||
command tar -x${tar_compression_flag}f "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
||||
command rm -f "$tmptarball" && \
|
||||
command mkdir -p "$VERSION_PATH" && \
|
||||
|
@ -1145,19 +1145,19 @@ nvm_install_node_binary() {
|
|||
if nvm_binary_available "$VERSION"; then
|
||||
local NVM_ARCH
|
||||
NVM_ARCH="$(nvm_get_arch)"
|
||||
if [ $NVM_ARCH = "armv6l" ] || [ $NVM_ARCH = "armv7l" ]; then
|
||||
if [ "_$NVM_ARCH" = '_armv6l' ] || [ "_$NVM_ARCH" = 'armv7l' ]; then
|
||||
NVM_ARCH="arm-pi"
|
||||
fi
|
||||
t="$VERSION-$NVM_OS-$NVM_ARCH"
|
||||
url="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-${t}.tar.gz"
|
||||
sum=`nvm_download -L -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt -o - | command grep node-${t}.tar.gz | command awk '{print $1}'`
|
||||
sum=`nvm_download -L -s "$NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt" -o - | command grep "node-${t}.tar.gz" | command awk '{print $1}'`
|
||||
local tmpdir
|
||||
tmpdir="$NVM_DIR/bin/node-${t}"
|
||||
local tmptarball
|
||||
tmptarball="$tmpdir/node-${t}.tar.gz"
|
||||
local NVM_INSTALL_ERRORED
|
||||
command mkdir -p "$tmpdir" && \
|
||||
nvm_download -L -C - --progress-bar $url -o "$tmptarball" || \
|
||||
nvm_download -L -C - --progress-bar "$url" -o "$tmptarball" || \
|
||||
NVM_INSTALL_ERRORED=true
|
||||
if grep '404 Not Found' "$tmptarball" >/dev/null; then
|
||||
NVM_INSTALL_ERRORED=true
|
||||
|
@ -1165,7 +1165,7 @@ nvm_install_node_binary() {
|
|||
fi
|
||||
if (
|
||||
[ "$NVM_INSTALL_ERRORED" != true ] && \
|
||||
nvm_checksum "$tmptarball" $sum && \
|
||||
nvm_checksum "$tmptarball" "$sum" && \
|
||||
command tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \
|
||||
command rm -f "$tmptarball" && \
|
||||
command mkdir -p "$VERSION_PATH" && \
|
||||
|
@ -1190,7 +1190,7 @@ nvm_install_node_source() {
|
|||
|
||||
local NVM_ARCH
|
||||
NVM_ARCH="$(nvm_get_arch)"
|
||||
if [ $NVM_ARCH = "armv6l" ] || [ $NVM_ARCH = "armv7l" ]; then
|
||||
if [ "_$NVM_ARCH" = '_armv6l' ] || [ "_$NVM_ARCH" = '_armv7l' ]; then
|
||||
ADDITIONAL_PARAMETERS="--without-snapshot $ADDITIONAL_PARAMETERS"
|
||||
fi
|
||||
|
||||
|
@ -1220,7 +1220,7 @@ nvm_install_node_source() {
|
|||
|
||||
if [ "`nvm_download -L -s -I "$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz" -o - 2>&1 | command grep '200 OK'`" != '' ]; then
|
||||
tarball="$NVM_NODEJS_ORG_MIRROR/$VERSION/node-$VERSION.tar.gz"
|
||||
sum=`nvm_download -L -s $NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt -o - | command grep "node-$VERSION.tar.gz" | command awk '{print $1}'`
|
||||
sum=`nvm_download -L -s "$NVM_NODEJS_ORG_MIRROR/$VERSION/SHASUMS.txt" -o - | command grep "node-${VERSION}.tar.gz" | command awk '{print $1}'`
|
||||
elif [ "`nvm_download -L -s -I "$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz" -o - | command grep '200 OK'`" != '' ]; then
|
||||
tarball="$NVM_NODEJS_ORG_MIRROR/node-$VERSION.tar.gz"
|
||||
fi
|
||||
|
@ -1229,8 +1229,8 @@ nvm_install_node_source() {
|
|||
[ -n "$tarball" ] && \
|
||||
command mkdir -p "$tmpdir" && \
|
||||
echo "Downloading $tarball..." && \
|
||||
nvm_download -L --progress-bar $tarball -o "$tmptarball" && \
|
||||
nvm_checksum "$tmptarball" $sum && \
|
||||
nvm_download -L --progress-bar "$tarball" -o "$tmptarball" && \
|
||||
nvm_checksum "$tmptarball" "$sum" && \
|
||||
command tar -xzf "$tmptarball" -C "$tmpdir" && \
|
||||
cd "$tmpdir/node-$VERSION" && \
|
||||
./configure --prefix="$VERSION_PATH" $ADDITIONAL_PARAMETERS && \
|
||||
|
@ -1378,7 +1378,7 @@ node_version_has_solaris_binary() {
|
|||
NODE_VERSION="$1"
|
||||
# Error out if $NODE_VERSION is actually an io.js version
|
||||
local STRIPPED_IOJS_VERSION
|
||||
STRIPPED_IOJS_VERSION="$(nvm_strip_iojs_prefix $NODE_VERSION)"
|
||||
STRIPPED_IOJS_VERSION="$(nvm_strip_iojs_prefix "$NODE_VERSION")"
|
||||
if [ "_$STRIPPED_IOJS_VERSION" != "_$NODE_VERSION" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
@ -1493,7 +1493,7 @@ nvm() {
|
|||
NVM_DEBUG_OUTPUT="$($NVM_DEBUG_COMMAND 2>&1)"
|
||||
echo >&2 "$NVM_DEBUG_COMMAND: $(nvm_sanitize_path "$NVM_DEBUG_OUTPUT")"
|
||||
done
|
||||
if [ "_$ZHS_HAS_SHWORDSPLIT_UNSET" = "_1" ] && nvm_has "unsetopt"; then
|
||||
if [ "$ZHS_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then
|
||||
unsetopt shwordsplit
|
||||
fi
|
||||
return 42
|
||||
|
@ -1678,7 +1678,7 @@ nvm() {
|
|||
local NVM_SUCCESS_MSG
|
||||
if nvm_is_iojs_version "$VERSION"; then
|
||||
NVM_PREFIX="$(nvm_iojs_prefix)"
|
||||
NVM_SUCCESS_MSG="Uninstalled io.js $(nvm_strip_iojs_prefix $VERSION)"
|
||||
NVM_SUCCESS_MSG="Uninstalled io.js $(nvm_strip_iojs_prefix "$VERSION")"
|
||||
else
|
||||
NVM_PREFIX="$(nvm_node_prefix)"
|
||||
NVM_SUCCESS_MSG="Uninstalled node $VERSION"
|
||||
|
@ -1692,7 +1692,7 @@ nvm() {
|
|||
echo "$NVM_SUCCESS_MSG"
|
||||
|
||||
# rm any aliases that point to uninstalled version.
|
||||
for ALIAS in `command grep -l $VERSION "$(nvm_alias_path)/*" 2>/dev/null`
|
||||
for ALIAS in `command grep -l "$VERSION" "$(nvm_alias_path)/*" 2>/dev/null`
|
||||
do
|
||||
nvm unalias "$(command basename "$ALIAS")"
|
||||
done
|
||||
|
@ -1918,7 +1918,7 @@ nvm() {
|
|||
OUTPUT="$(nvm use "$VERSION" >/dev/null && node $ARGS)"
|
||||
EXIT_CODE="$?"
|
||||
fi
|
||||
if [ $ZHS_HAS_SHWORDSPLIT_UNSET -eq 1 ] && nvm_has "unsetopt"; then
|
||||
if [ "$ZHS_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then
|
||||
unsetopt shwordsplit
|
||||
fi
|
||||
if [ -n "$OUTPUT" ]; then
|
||||
|
@ -1956,7 +1956,7 @@ nvm() {
|
|||
fi
|
||||
|
||||
[ $NVM_SILENT -eq 1 ] || echo "Running node $VERSION$(nvm_print_npm_version)"
|
||||
NODE_VERSION="$VERSION" $NVM_DIR/nvm-exec "$@"
|
||||
NODE_VERSION="$VERSION" "$NVM_DIR/nvm-exec" "$@"
|
||||
;;
|
||||
"ls" | "list" )
|
||||
local NVM_LS_OUTPUT
|
||||
|
@ -2181,7 +2181,7 @@ $NVM_LS_REMOTE_POST_MERGED_OUTPUT" | command grep -v "N/A" | command sed '/^$/d'
|
|||
set +f; unset IFS # restore variable expansion in case $LINKS was empty
|
||||
;;
|
||||
"clear-cache" )
|
||||
command rm -f $NVM_DIR/v* "$(nvm_version_dir)" 2>/dev/null
|
||||
command rm -f "$NVM_DIR/v*" "$(nvm_version_dir)" 2>/dev/null
|
||||
echo "Cache cleared."
|
||||
;;
|
||||
"version" )
|
||||
|
|
Loading…
Reference in New Issue