Merge pull request #1684 from PeterDaveHello/ShellCheck-v0.4.7-fixes

ShellCheck v0.4.7 fixes
Jordan Harband 2017-12-13 14:49:34 -08:00 committed by GitHub
commit 2a259435c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 23 deletions

View File

@ -10,6 +10,7 @@ __nvm_generate_completion()
{ {
declare current_word declare current_word
current_word="${COMP_WORDS[COMP_CWORD]}" current_word="${COMP_WORDS[COMP_CWORD]}"
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$1" -- "$current_word")) COMPREPLY=($(compgen -W "$1" -- "$current_word"))
return 0 return 0
} }

View File

@ -85,7 +85,7 @@ install_nvm_from_git() {
if [ -d "$INSTALL_DIR/.git" ]; then if [ -d "$INSTALL_DIR/.git" ]; then
echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git" echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git"
command printf "\r=> " command printf '\r=> '
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin tag "$(nvm_latest_version)" --depth=1 2> /dev/null || { command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin tag "$(nvm_latest_version)" --depth=1 2> /dev/null || {
echo >&2 "Failed to update nvm, run 'git fetch' in $INSTALL_DIR yourself." echo >&2 "Failed to update nvm, run 'git fetch' in $INSTALL_DIR yourself."
exit 1 exit 1
@ -93,7 +93,7 @@ install_nvm_from_git() {
else else
# Cloning to $INSTALL_DIR # Cloning to $INSTALL_DIR
echo "=> Downloading nvm from git to '$INSTALL_DIR'" echo "=> Downloading nvm from git to '$INSTALL_DIR'"
command printf "\r=> " command printf '\r=> '
mkdir -p "${INSTALL_DIR}" mkdir -p "${INSTALL_DIR}"
if [ "$(ls -A "${INSTALL_DIR}")" ]; then if [ "$(ls -A "${INSTALL_DIR}")" ]; then
command git init "${INSTALL_DIR}" || { command git init "${INSTALL_DIR}" || {
@ -325,8 +325,9 @@ nvm_do_install() {
local PROFILE_INSTALL_DIR local PROFILE_INSTALL_DIR
PROFILE_INSTALL_DIR="$(nvm_install_dir| sed "s:^$HOME:\$HOME:")" PROFILE_INSTALL_DIR="$(nvm_install_dir| sed "s:^$HOME:\$HOME:")"
SOURCE_STR="\nexport NVM_DIR=\"${PROFILE_INSTALL_DIR}\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && \\. \"\$NVM_DIR/nvm.sh\" # This loads nvm\n" SOURCE_STR="\\nexport NVM_DIR=\"${PROFILE_INSTALL_DIR}\"\\n[ -s \"\$NVM_DIR/nvm.sh\" ] && \\. \"\$NVM_DIR/nvm.sh\" # This loads nvm\\n"
COMPLETION_STR="[ -s \"\$NVM_DIR/bash_completion\" ] && \\. \"\$NVM_DIR/bash_completion\" # This loads nvm bash_completion\n" # shellcheck disable=SC2016
COMPLETION_STR='[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion\n'
BASH_OR_ZSH=false BASH_OR_ZSH=false
if [ -z "${NVM_PROFILE-}" ] ; then if [ -z "${NVM_PROFILE-}" ] ; then

36
nvm.sh
View File

@ -53,7 +53,7 @@ nvm_command_info() {
INFO="$(which "${COMMAND}") ($(type "${COMMAND}" | command awk '{ $1=$2=$3=$4="" ;print }' | command sed -e 's/^\ *//g' -Ee "s/\`|'//g" ))" 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 elif type "${COMMAND}" | nvm_grep -q "^${COMMAND} is an alias for"; then
INFO="$(which "${COMMAND}") ($(type "${COMMAND}" | command awk '{ $1=$2=$3=$4=$5="" ;print }' | command sed 's/^\ *//g'))" 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 elif type "${COMMAND}" | nvm_grep -q "^${COMMAND} is \\/"; then
INFO="$(type "${COMMAND}" | command awk '{print $3}')" INFO="$(type "${COMMAND}" | command awk '{print $3}')"
else else
INFO="$(type "${COMMAND}")" INFO="$(type "${COMMAND}")"
@ -84,7 +84,7 @@ nvm_get_latest() {
if nvm_curl_use_compression; then if nvm_curl_use_compression; then
CURL_COMPRESSED_FLAG="--compressed" CURL_COMPRESSED_FLAG="--compressed"
fi fi
NVM_LATEST_URL="$(curl ${CURL_COMPRESSED_FLAG:-} -q -w "%{url_effective}\n" -L -s -S http://latest.nvm.sh -o /dev/null)" NVM_LATEST_URL="$(curl ${CURL_COMPRESSED_FLAG:-} -q -w "%{url_effective}\\n" -L -s -S http://latest.nvm.sh -o /dev/null)"
elif nvm_has "wget"; then elif nvm_has "wget"; then
NVM_LATEST_URL="$(wget http://latest.nvm.sh --server-response -O /dev/null 2>&1 | command awk '/^ Location: /{DEST=$2} END{ print DEST }')" NVM_LATEST_URL="$(wget http://latest.nvm.sh --server-response -O /dev/null 2>&1 | command awk '/^ Location: /{DEST=$2} END{ print DEST }')"
else else
@ -645,16 +645,16 @@ nvm_print_formatted_alias() {
DEST_FORMAT='%s' DEST_FORMAT='%s'
VERSION_FORMAT='%s' VERSION_FORMAT='%s'
local NEWLINE local NEWLINE
NEWLINE="\n" NEWLINE='\n'
if [ "_${DEFAULT}" = '_true' ]; then if [ "_${DEFAULT}" = '_true' ]; then
NEWLINE=" (default)\n" NEWLINE=' (default)\n'
fi fi
local ARROW local ARROW
ARROW='->' ARROW='->'
if [ -z "${NVM_NO_COLORS}" ] && nvm_has_colors; then if [ -z "${NVM_NO_COLORS}" ] && nvm_has_colors; then
ARROW='\033[0;90m->\033[0m' ARROW='\033[0;90m->\033[0m'
if [ "_${DEFAULT}" = '_true' ]; then if [ "_${DEFAULT}" = '_true' ]; then
NEWLINE=" \033[0;37m(default)\033[0m\n" NEWLINE=' \033[0;37m(default)\033[0m\n'
fi fi
if [ "_${VERSION}" = "_${NVM_CURRENT-}" ]; then if [ "_${VERSION}" = "_${NVM_CURRENT-}" ]; then
ALIAS_FORMAT='\033[0;32m%s\033[0m' ALIAS_FORMAT='\033[0;32m%s\033[0m'
@ -832,7 +832,7 @@ nvm_resolve_alias() {
break break
fi fi
SEEN_ALIASES="${SEEN_ALIASES}\n${ALIAS_TEMP}" SEEN_ALIASES="${SEEN_ALIASES}\\n${ALIAS_TEMP}"
ALIAS="${ALIAS_TEMP}" ALIAS="${ALIAS_TEMP}"
done done
@ -1021,25 +1021,23 @@ nvm_ls() {
PATTERN='v' PATTERN='v'
SEARCH_PATTERN='.*' SEARCH_PATTERN='.*'
else else
SEARCH_PATTERN="$(echo "${PATTERN}" | command sed "s#\.#\\\.#g;")" SEARCH_PATTERN="$(echo "${PATTERN}" | command sed 's#\.#\\\.#g;')"
fi fi
if [ -n "${NVM_DIRS_TO_SEARCH1}${NVM_DIRS_TO_SEARCH2}${NVM_DIRS_TO_SEARCH3}" ]; then if [ -n "${NVM_DIRS_TO_SEARCH1}${NVM_DIRS_TO_SEARCH2}${NVM_DIRS_TO_SEARCH3}" ]; then
VERSIONS="$(command find "${NVM_DIRS_TO_SEARCH1}"/* "${NVM_DIRS_TO_SEARCH2}"/* "${NVM_DIRS_TO_SEARCH3}"/* -name . -o -type d -prune -o -path "${PATTERN}*" \ VERSIONS="$(command find "${NVM_DIRS_TO_SEARCH1}"/* "${NVM_DIRS_TO_SEARCH2}"/* "${NVM_DIRS_TO_SEARCH3}"/* -name . -o -type d -prune -o -path "${PATTERN}*" \
| command sed -e " | command sed -e "
s#${NVM_VERSION_DIR_IOJS}/#versions/${NVM_IOJS_PREFIX}/#; s#${NVM_VERSION_DIR_IOJS}/#versions/${NVM_IOJS_PREFIX}/#;
s#^${NVM_DIR}/##; s#^${NVM_DIR}/##;
\#^[^v]# d; \\#^[^v]# d;
\#^versions\$# d; \\#^versions\$# d;
s#^versions/##; s#^versions/##;
s#^v#${NVM_NODE_PREFIX}/v#; s#^v#${NVM_NODE_PREFIX}/v#;
\#${SEARCH_PATTERN}# !d; \\#${SEARCH_PATTERN}# !d;
" \ " \
-e "s#^\([^/]\{1,\}\)/\(.*\)\$#\2.\1#;" \ -e 's#^\([^/]\{1,\}\)/\(.*\)$#\2.\1#;' \
| command sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n \ | command sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n \
| command sed " | command sed -e 's#\(.*\)\.\([^\.]\{1,\}\)$#\2-\1#;' \
s#\(.*\)\.\([^\.]\{1,\}\)\$#\2-\1#; -e "s#^${NVM_NODE_PREFIX}-##;" \
s#^${NVM_NODE_PREFIX}-##;
" \
)" )"
fi fi
@ -1405,7 +1403,7 @@ nvm_print_versions() {
LTS="${LTS##Latest }" LTS="${LTS##Latest }"
LTS_LENGTH="${#LTS}" LTS_LENGTH="${#LTS}"
if [ "${NVM_HAS_COLORS-}" = '1' ]; then if [ "${NVM_HAS_COLORS-}" = '1' ]; then
LTS_FORMAT=" \033[1;32m%${LTS_LENGTH}s\033[0m" LTS_FORMAT=" \\033[1;32m%${LTS_LENGTH}s\\033[0m"
else else
LTS_FORMAT=" %${LTS_LENGTH}s" LTS_FORMAT=" %${LTS_LENGTH}s"
fi fi
@ -1413,15 +1411,15 @@ nvm_print_versions() {
*) *)
LTS_LENGTH="${#LTS}" LTS_LENGTH="${#LTS}"
if [ "${NVM_HAS_COLORS-}" = '1' ]; then if [ "${NVM_HAS_COLORS-}" = '1' ]; then
LTS_FORMAT=" \033[0;37m%${LTS_LENGTH}s\033[0m" LTS_FORMAT=" \\033[0;37m%${LTS_LENGTH}s\\033[0m"
else else
LTS_FORMAT=" %${LTS_LENGTH}s" LTS_FORMAT=" %${LTS_LENGTH}s"
fi fi
;; ;;
esac esac
command printf -- "${FORMAT}${LTS_FORMAT}\n" "$VERSION" " $LTS" command printf -- "${FORMAT}${LTS_FORMAT}\\n" "$VERSION" " $LTS"
else else
command printf -- "${FORMAT}\n" "$VERSION" command printf -- "${FORMAT}\\n" "$VERSION"
fi fi
done done
} }