Skip to content
Open
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
16 changes: 11 additions & 5 deletions tool/config/config_autocomplete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ __gamer_configure_autocomplete() {
local configure_filename configure_command
if [[ "${COMP_WORDS[0]}" == "python"* ]]; then
configure_filename=${COMP_WORDS[1]}
configure_command="${COMP_WORDS[0]} ${COMP_WORDS[1]}"
local alias_def
alias_def=$(alias -- "${COMP_WORDS[0]}" 2>/dev/null)
if [[ -n "$alias_def" ]]; then
eval "configure_command=( ${alias_def#alias ${COMP_WORDS[0]}=} ${configure_filename} )"
else
configure_command=( "${COMP_WORDS[0]}" "${COMP_WORDS[1]}" )
fi
else
configure_filename=${COMP_WORDS[0]}
configure_command="${COMP_WORDS[0]}"
configure_command=( "${COMP_WORDS[0]}" )
fi

__gamer_check_gamer_info $configure_filename
Expand All @@ -45,7 +51,7 @@ __gamer_configure_autocomplete() {
local sub="${COMP_WORDS[COMP_CWORD-1]}"
local cur="${COMP_WORDS[COMP_CWORD]}"

all_options=$(${configure_command} --autocomplete_info=all)
all_options=$(eval ${configure_command[@]} --autocomplete_info=all)
IFS=' ' read -r -a all_option_array <<< "${all_options}"

COMPREPLY=() # NOTE: please add a space when ending the option
Expand All @@ -55,7 +61,7 @@ __gamer_configure_autocomplete() {
do
# --option=xx
if [[ "$opt" == "$subsub=" && "=" == "$sub" ]]; then
sub_options=$(${configure_command} --autocomplete_info="$opt")
sub_options=$(eval ${configure_command[@]} --autocomplete_info="$opt")
IFS=' ' read -r -a sub_option_array <<< "${sub_options}"
for opt2 in "${sub_option_array[@]}"
do
Expand All @@ -66,7 +72,7 @@ __gamer_configure_autocomplete() {
break
# --option, --option xxx, or --option=
elif [[ "$opt" == "$sub=" ]]; then
sub_options=$(${configure_command} --autocomplete_info="$opt")
sub_options=$(eval ${configure_command[@]} --autocomplete_info="$opt")
IFS=' ' read -r -a sub_option_array <<< "${sub_options}"
for opt2 in "${sub_option_array[@]}"
do
Expand Down