Skip to content

Commit da71b3f

Browse files
committed
path: Fix bash 4.4 readonly variable error
Bash 4.4 was released last night, and `./go test` failed to run due to `_GO_SEARCH_PATHS` being redefined. This change puts a guard around the assignment so it isn't attempted if `_GO_SEARCH_PATHS` is not null.
1 parent d5ffa1a commit da71b3f

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/path

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#! /bin/bash
22

3-
if [[ -d "$_GO_SCRIPTS_DIR/plugins" ]]; then
4-
declare -r _GO_PLUGINS_DIR="$_GO_SCRIPTS_DIR/plugins"
5-
shopt -s nullglob
6-
declare -r _GO_PLUGINS_PATHS=("$_GO_PLUGINS_DIR" "$_GO_PLUGINS_DIR"/*/bin)
7-
shopt -u nullglob
8-
declare -r _GO_SEARCH_PATHS=(\
9-
"$_GO_CORE_DIR/libexec" "${_GO_PLUGINS_PATHS[@]}" "$_GO_SCRIPTS_DIR")
10-
else
11-
declare -r _GO_SEARCH_PATHS=("$_GO_CORE_DIR/libexec" "$_GO_SCRIPTS_DIR")
3+
if [[ -z "${_GO_SEARCH_PATHS[*]}" ]]; then
4+
if [[ -d "$_GO_SCRIPTS_DIR/plugins" ]]; then
5+
declare -r _GO_PLUGINS_DIR="$_GO_SCRIPTS_DIR/plugins"
6+
shopt -s nullglob
7+
declare -r _GO_PLUGINS_PATHS=("$_GO_PLUGINS_DIR" "$_GO_PLUGINS_DIR"/*/bin)
8+
shopt -u nullglob
9+
declare -r _GO_SEARCH_PATHS=(\
10+
"$_GO_CORE_DIR/libexec" "${_GO_PLUGINS_PATHS[@]}" "$_GO_SCRIPTS_DIR")
11+
else
12+
declare -r _GO_SEARCH_PATHS=("$_GO_CORE_DIR/libexec" "$_GO_SCRIPTS_DIR")
13+
fi
1214
fi
1315

1416
_@go.list_available_commands() {

0 commit comments

Comments
 (0)