Skip to content

Commit 955f977

Browse files
committed
bash 3.0 compability and return instead of exit
1 parent 6142f8f commit 955f977

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

bash_completions.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ __%[1]s_handle_reply()
7272
else
7373
allflags=("${flags[*]} ${two_word_flags[*]}")
7474
fi
75-
mapfile -t COMPREPLY < <(compgen -W "${allflags[*]}" -- "$cur")
75+
COMPREPLY=()
76+
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "${allflags[*]}" -- "$cur")
77+
7678
if [[ $(type -t compopt) = "builtin" ]]; then
7779
[[ "${COMPREPLY[0]}" == *= ]] || compopt +o nospace
7880
fi
@@ -122,10 +124,12 @@ __%[1]s_handle_reply()
122124
if [[ ${#must_have_one_flag[@]} -ne 0 ]]; then
123125
completions+=("${must_have_one_flag[@]}")
124126
fi
125-
mapfile -t COMPREPLY < <(compgen -W "${completions[*]}" -- "$cur")
127+
COMPREPLY=()
128+
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "${completions[*]}" -- "$cur")
126129
127130
if [[ ${#COMPREPLY[@]} -eq 0 && ${#noun_aliases[@]} -gt 0 && ${#must_have_one_noun[@]} -ne 0 ]]; then
128-
mapfile -t COMPREPLY < <(compgen -W "${noun_aliases[*]}" -- "$cur")
131+
COMPREPLY=()
132+
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "${noun_aliases[*]}" -- "$cur")
129133
fi
130134
131135
if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
@@ -160,7 +164,7 @@ __%[1]s_handle_filename_extension_flag()
160164
__%[1]s_handle_subdirs_in_dir_flag()
161165
{
162166
local dir="$1"
163-
pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 || exit
167+
pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 || return
164168
}
165169
166170
__%[1]s_handle_flag()

0 commit comments

Comments
 (0)