Skip to content

Commit

Permalink
Merge c1423d7 into b8d7140
Browse files Browse the repository at this point in the history
  • Loading branch information
nkakouros authored Dec 12, 2017
2 parents b8d7140 + c1423d7 commit 9fcba3a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
14 changes: 9 additions & 5 deletions go-core.bash
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ fi
declare -r -x _GO_CORE_DIR="$PWD"

# Set _GO_STANDALONE if your script is a standalone program.
#
declare -x _GO_STANDALONE="${_GO_STANDALONE-}"

# See the "Standalone mode" section of README.md for more information.
if [[ -z "$_GO_STANDALONE" ]]; then
if [[ -n "$_GO_STANDALONE" ]]; then
cd "$_GO_ROOTDIR" || exit 1
else
cd "$__go_orig_dir" || exit 1
Expand Down Expand Up @@ -120,7 +121,7 @@ declare -r -x _GO_TEST_DIR="${_GO_TEST_DIR:-tests}"
declare -r -x _GO_SCRIPT="$_GO_ROOTDIR/${0##*/}"

# The name of either the ./go script itself or the shell function invoking it.
declare -r -x _GO_CMD="${_GO_CMD:=$0}"
declare -r -x _GO_CMD="${_GO_CMD:-$0}"

# The array of command line arguments comprising the ./go command name after
# _GO_CMD.
Expand Down Expand Up @@ -151,11 +152,14 @@ declare _GO_SEARCH_PATHS=()
# Should be an absolute path. Use this for stubbing out scripts during testing
# or debugging, or for experimenting with new implementations of existing
# scripts.
declare _GO_INJECT_SEARCH_PATH="$_GO_INJECT_SEARCH_PATH"
declare _GO_INJECT_SEARCH_PATH="${_GO_INJECT_SEARCH_PATH-}"

# Directory to search for module scripts first.
# Similar to _GO_INJECT_SEARCH_PATHS above, but for `. "$_GO_USE_MODULES"`.
declare _GO_INJECT_MODULE_PATH="$_GO_INJECT_MODULE_PATH"
declare _GO_INJECT_MODULE_PATH="${_GO_INJECT_MODULE_PATH-}"

# Read from the environment and used in output formatting
COLUMNS="${COLUMNS-}"

# Invokes printf builtin, then folds output to $COLUMNS width
#
Expand Down
3 changes: 2 additions & 1 deletion lib/complete
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@
fi
unset "compreply[$compgen_exit_index]"

add_slashes='false'
if [[ "$1" =~ ^-[df]$ ]]; then
add_slashes='true'
fi

for reply_item in "${compreply[@]}"; do
# Since we're not using -o filenames, we must add slashes to dir names.
# Since we're using -o nospace, we must add a space to a single match.
if [[ -n "$add_slashes" && -d "$reply_item" ]]; then
if [[ "$add_slashes" == 'true' && -d "$reply_item" ]]; then
printf -- '%s/\n' "$reply_item"
elif [[ "${#compreply[@]}" -eq '1' && ! $reply_item =~ [\ /]$ ]]; then
printf -- '%s \n' "$reply_item"
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/set-search-paths
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ _@go.set_search_paths() {
# A plugin's own local plugin paths will appear before inherited ones. If
# there is a version incompatibility issue with other installed plugins, this
# allows a plugin's preferred version to take precedence.
@go.search_plugins '_@go.set_search_paths_add_plugin_paths'
@go.search_plugins '_@go.set_search_paths_add_plugin_paths' || :
_GO_SEARCH_PATHS+=("${_GO_PLUGINS_PATHS[@]}")
}

Expand Down
8 changes: 7 additions & 1 deletion libexec/env
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ END_OF_HELP
return 1
fi

read -r -d '' env_script < "$shell_impl"
read -r -d '' env_script < "$shell_impl" && exit_code=0 || exit_code=$?
if [[ "$exit_code" -gt 1 ]]; then
# Due to encountering EOL, 'read' will return with '1'. To support 'set -e'
# we only return the exit code if an actual error has occured ($? -gt 1).
return $exit_code
fi

env_script="${env_script//_go_func/$go_func}"
env_script="${env_script//\$_GO_ROOTDIR/$_GO_ROOTDIR}"
echo "${env_script//\$_GO_SCRIPT/$_GO_SCRIPT}"
Expand Down

0 comments on commit 9fcba3a

Please sign in to comment.