From 0cd8f38b8a74942a0b0d377757bc921f193dee68 Mon Sep 17 00:00:00 2001 From: "Deavon M. McCaffery" Date: Mon, 5 Mar 2018 19:14:16 -0800 Subject: [PATCH] fix: prompt updates on sierra --- src/scripts/add-bookmark.sh | 2 +- src/scripts/add-var.sh | 4 ++-- src/scripts/dotnet-install.sh | 2 +- src/scripts/git-extensions.sh | 6 +++--- src/scripts/git-extras.sh | 16 ++++++++-------- src/scripts/open-url.sh | 2 +- src/scripts/post/post-update-prompt.sh | 6 +++++- src/scripts/remove-backup.sh | 2 +- src/scripts/remove-bookmark.sh | 2 +- src/scripts/remove-var.sh | 2 +- src/scripts/set-nvm.sh | 16 +++++----------- src/scripts/update-prompt.sh | 8 ++++---- uname/install-Darwin.sh | 6 +++--- 13 files changed, 36 insertions(+), 38 deletions(-) diff --git a/src/scripts/add-bookmark.sh b/src/scripts/add-bookmark.sh index b23ea22..d6cd719 100644 --- a/src/scripts/add-bookmark.sh +++ b/src/scripts/add-bookmark.sh @@ -11,7 +11,7 @@ add-bookmark-usage() { add-bookmark() { # make sure that a bookmark was specified. - if [ -z ${1+x} ]; then + if [ -z ${1:-} ]; then echo 'add-bookmark: missing ' add-bookmark-usage return diff --git a/src/scripts/add-var.sh b/src/scripts/add-var.sh index ec1576f..7561179 100644 --- a/src/scripts/add-var.sh +++ b/src/scripts/add-var.sh @@ -12,13 +12,13 @@ add-var-usage() { add-var() { # make sure that a bookmark was specified. - if [ -z ${1+x} ]; then + if [ -z ${1:-} ]; then echo 'add-var: missing ' add-var-usage return fi - if [ -z ${2+x} ]; then + if [ -z ${2:-} ]; then echo 'add-var: missing ' add-var-usage return diff --git a/src/scripts/dotnet-install.sh b/src/scripts/dotnet-install.sh index 8dbc4f2..6269def 100644 --- a/src/scripts/dotnet-install.sh +++ b/src/scripts/dotnet-install.sh @@ -58,7 +58,7 @@ dotnet-install() { shift done - if [ -z ${DOTNET_INSTALL_DIR+x} ]; then + if [ -z ${DOTNET_INSTALL_DIR:-} ]; then export DOTNET_INSTALL_DIR=$HOME/.dotnet fi diff --git a/src/scripts/git-extensions.sh b/src/scripts/git-extensions.sh index eb6479d..87abd95 100644 --- a/src/scripts/git-extensions.sh +++ b/src/scripts/git-extensions.sh @@ -13,12 +13,12 @@ git-flow-clone() { local URL=$1 local NAME=$2 - if [ -z ${URL+x} ]; then + if [ -z ${URL:-} ]; then echo 'git-clone: you must specify a url, which is the first parameter.' return fi - if [ -z ${NAME+x} ]; then + if [ -z ${NAME:-} ]; then echo 'git-clone: you must specify a directory name, which is the second parameter.' return fi @@ -48,7 +48,7 @@ git-flow-init() { local NAME=$1 - if [ -z ${NAME+x} ]; then + if [ -z ${NAME:-} ]; then NAME='.' fi diff --git a/src/scripts/git-extras.sh b/src/scripts/git-extras.sh index d1ff07a..c1c69fc 100644 --- a/src/scripts/git-extras.sh +++ b/src/scripts/git-extras.sh @@ -17,22 +17,22 @@ git-sha() { local REPO_NAME=$2 local BRANCH_NAME=$3 - if [ -z ${ORG_NAME+x} ]; then - local ORG_NAME='automotiveMastermind' + if [ -z ${ORG_NAME:-} ]; then + ORG_NAME='automotiveMastermind' fi - if [ -z ${REPO_NAME+x} ]; then - local REPO_NAME='prompt' + if [ -z ${REPO_NAME:-} ]; then + REPO_NAME='prompt' fi - if [ -z ${BRANCH_NAME+x} ]; then - local BRANCH_NAME='master' + if [ -z ${BRANCH_NAME:-} ]; then + BRANCH_NAME='master' fi local CURL_OPT='-s' if [ ! -z "${GH_TOKEN:-}" ]; then - local CURL_OPT="$CURL_OPT -H 'Authorization: $GH_TOKEN'" + CURL_OPT="$CURL_OPT -H 'Authorization: $GH_TOKEN'" fi local SHA_URI=https://api.github.com/repos/$ORG_NAME/$REPO_NAME/commits/$BRANCH_NAME @@ -56,7 +56,7 @@ git-sha() { git-token() { local GH_TOKEN=$1 - if [ -z ${GH_TOKEN+x} ]; then + if [ -z ${GH_TOKEN:-} ]; then echo 'usage: git-token [token]' else add-var GH_TOKEN $GH_TOKEN diff --git a/src/scripts/open-url.sh b/src/scripts/open-url.sh index 6d95692..c40572a 100644 --- a/src/scripts/open-url.sh +++ b/src/scripts/open-url.sh @@ -7,7 +7,7 @@ fi open-url() { local url="$1" - if [ -z ${1+x} ]; then + if [ -z ${1:-} ]; then echo 'open-url: url must be supplied' return 1 fi diff --git a/src/scripts/post/post-update-prompt.sh b/src/scripts/post/post-update-prompt.sh index 8de49b3..b81b904 100644 --- a/src/scripts/post/post-update-prompt.sh +++ b/src/scripts/post/post-update-prompt.sh @@ -1,5 +1,9 @@ #!/usr/bin/env bash -if [ ! -z "${AM_PROMPT_UPDATE:-}" ]; then +if [ "${AM_PROMPT_UPDATE}" == "1" ]; then + update-prompt +fi + +if [ "${AM_PROMPT_UPDATE}" == "true" ]; then update-prompt fi \ No newline at end of file diff --git a/src/scripts/remove-backup.sh b/src/scripts/remove-backup.sh index d56ebbd..d1a71a3 100644 --- a/src/scripts/remove-backup.sh +++ b/src/scripts/remove-backup.sh @@ -7,7 +7,7 @@ fi remove-backup() { local BACKUP=$1 - if [ -z ${BACKUP+x} ]; then + if [ -z ${BACKUP:-} ]; then BACKUP='prompt' fi diff --git a/src/scripts/remove-bookmark.sh b/src/scripts/remove-bookmark.sh index 0ad2839..92be703 100644 --- a/src/scripts/remove-bookmark.sh +++ b/src/scripts/remove-bookmark.sh @@ -31,7 +31,7 @@ remove-bookmark() { ROW=$(grep -s -m 1 \"$PWD\"$ "$USER_PATH/bookmarks.sh") fi - if [ -z ${ROW+x} ]; then + if [ -z ${ROW:-} ]; then echo 'remove-bookmark: no bookmark was found for the specified title or path.' return 1 diff --git a/src/scripts/remove-var.sh b/src/scripts/remove-var.sh index f46d589..879c0ce 100644 --- a/src/scripts/remove-var.sh +++ b/src/scripts/remove-var.sh @@ -23,7 +23,7 @@ remove-var() { REMOVE=$(grep -s -m 1 ^$VARIABLE $VAR_PATH) unset $VARIABLE 1>/dev/null 2>&1 - if [ -z ${REMOVE+x} ]; then + if [ -z ${REMOVE:-} ]; then echo 'remove-var: no variable was declared for the specified name' return 1 diff --git a/src/scripts/set-nvm.sh b/src/scripts/set-nvm.sh index e440a5b..3e405c3 100644 --- a/src/scripts/set-nvm.sh +++ b/src/scripts/set-nvm.sh @@ -6,14 +6,6 @@ fi __prompt-set-nvm() { - local NVM_PATH=$(which nvm) - - if [ -z ${NVM_PATH+x} ]; then - nvm use --lts --delete-prefix - eval "$(npm completion)" - return - fi - NVM_PATH=$(brew --prefix nvm 2>/dev/null) if [ -z ${NVM_PATH+x} ]; then @@ -25,7 +17,9 @@ __prompt-set-nvm() return fi - source "$NVM_PATH/nvm.sh" - nvm use --lts --delete-prefix - eval "$(npm completion)" + if [ -f "$NVM_PATH/nvm.sh" ]; then + export NVM_DIR="${HOME}/.nvm" + source "$NVM_PATH/nvm.sh" + eval "$(npm completion)" + fi } \ No newline at end of file diff --git a/src/scripts/update-prompt.sh b/src/scripts/update-prompt.sh index a71b849..f9131e9 100644 --- a/src/scripts/update-prompt.sh +++ b/src/scripts/update-prompt.sh @@ -8,21 +8,21 @@ update-prompt() { local SHA=$(git-sha) local SHA_PATH=$HOME/.am/prompt/.sha - if [ "${1+x}" = "--force" ]; then + if [ "${1:-}" = "--force" ]; then rm -rf $SHA_PATH 1>/dev/null 2>&1 fi remove-backup - if [ -f ${SHA_PATH+x} ]; then + if [ -f ${SHA_PATH:-} ]; then CURRENT_SHA=$(cat $SHA_PATH) - if [ -z ${SHA+x} ]; then + if [ -z ${SHA:-} ]; then echo "prompt: SHA cannot be retrieved, which could be related to rate limiting." return 1 fi - if [ "${SHA+x}" = "${CURRENT_SHA+x}" ]; then + if [ "${SHA:-}" = "${CURRENT_SHA:-}" ]; then echo "prompt: latest version already installed: $SHA" return 0 fi diff --git a/uname/install-Darwin.sh b/uname/install-Darwin.sh index 710c516..4b4d4ea 100644 --- a/uname/install-Darwin.sh +++ b/uname/install-Darwin.sh @@ -46,12 +46,12 @@ __prompt-install-darwin() { local NVM_PATH=$(brew --prefix nvm) - if [ -d $NVM_PATH ]; then + if [ -f "$NVM_PATH/nvm.sh" ]; then __prompt-success 'setting up nvm...' - + export NVM_DIR="${HOME}/.nvm" source "$NVM_PATH/nvm.sh" nvm install --lts 1>/dev/null 2>&1 - nvm use --lts --delete-prefix 1>/dev/null 2>&1 + nvm use --lts --delete-prefix --silent 1>/dev/null 2>&1 fi __prompt-success 'setting git credential helper to use the macOS keychain'