Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions go-core.bash
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,15 @@ [email protected]_scripts_dir() {
"directory" >&2
return 1
fi

# If '_GO_SCRIPTS_DIR' was set to '_GO_ROOTDIR', 'scripts_dir' would end up
# with a trailing space. This would cause issues later in the code where path
# comparison would fail as paths would result in double slashes before
# command script paths.
if [[ "${scripts_dir: -1}" == '/' ]]; then
scripts_dir="${scripts_dir%/}"
fi

_GO_SCRIPTS_DIR="$scripts_dir"
}

Expand Down
7 changes: 6 additions & 1 deletion lib/internal/commands
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ [email protected]_commands() {
for scripts_dir in "$@"; do
scripts=()

# Together with the existence of a potential script, we are also excluding
# the './go' itself. This is relevant for the case a user has set
# '_GO_SCRIPTS_DIR' to '_GO_ROOTDIR'. In that case, the './go' script would
# end up being considered a command script.
for script in "$scripts_dir"/*; do
if [[ -f "$script" && -x "$script" ]]; then
if [[ -f "$script" && -x "$script" &&
"$script" != "$_GO_ROOTDIR/$_GO_CMD" ]]; then
scripts+=("$script")
fi
done
Expand Down