@@ -10,7 +10,6 @@ give_comps() {
1010 echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
1111 echo $' local result=()'
1212 echo $' local want_options=0'
13- echo $' local dynamic_prefix="__completely_dynamic__"'
1413 echo $' '
1514 echo $' # words the user already typed (excluding the command itself)'
1615 echo $' local used=()'
@@ -22,29 +21,19 @@ give_comps() {
2221 echo $' # Completing a non-option: drop options and already-used words.'
2322 echo $' [[ "${cur:0:1}" == "-" ]] && want_options=1'
2423 echo $' for word in "${words[@]}"; do'
25- echo $' local candidates=("$word")'
26- echo $' if [[ "$word" == "$dynamic_prefix"* ]]; then'
27- echo $' word="${word#"$dynamic_prefix"}"'
28- echo $' word="${word//$\'\r\' / }"'
29- echo $' word="${word//$\'\n\' / }"'
30- echo $' read -r -a candidates <<<"$word"'
24+ echo $' if ((!want_options)); then'
25+ echo $' [[ "${word:0:1}" == "-" ]] && continue'
26+ echo $' '
27+ echo $' for u in "${used[@]}"; do'
28+ echo $' if [[ "$u" == "$word" ]]; then'
29+ echo $' continue 2'
30+ echo $' fi'
31+ echo $' done'
3132 echo $' fi'
3233 echo $' '
33- echo $' for candidate in "${candidates[@]}"; do'
34- echo $' if ((!want_options)); then'
35- echo $' [[ "${candidate:0:1}" == "-" ]] && continue'
36- echo $' '
37- echo $' for u in "${used[@]}"; do'
38- echo $' if [[ "$u" == "$candidate" ]]; then'
39- echo $' continue 2'
40- echo $' fi'
41- echo $' done'
42- echo $' fi'
43- echo $' '
44- echo $' # compgen -W expects shell-escaped words in one space-delimited string.'
45- echo $' printf -v candidate \' %q\' "$candidate"'
46- echo $' result+=("$candidate")'
47- echo $' done'
34+ echo $' # compgen -W expects shell-escaped words in one space-delimited string.'
35+ echo $' printf -v word \' %q\' "$word"'
36+ echo $' result+=("$word")'
4837 echo $' done'
4938 echo $' '
5039 echo $' echo "${result[*]}"'
@@ -62,22 +51,27 @@ give_comps() {
6251 echo $' '
6352 echo $' case "$compline" in'
6453 echo $' \' status\' *\' --branch\' )'
65- echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "__completely_dynamic__$(git branch --format=\' %(refname:short)\' 2>/dev/null)")" -- "$cur")'
54+ echo $' # shellcheck disable=SC2046 # intentional splitting for dynamic $(...) completions'
55+ echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter $(git branch --format=\' %(refname:short)\' 2>/dev/null))" -- "$cur")'
6656 echo $' ;;'
6757 echo $' '
6858 echo $' \' status\' *\' -b\' )'
69- echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "__completely_dynamic__$(git branch --format=\' %(refname:short)\' 2>/dev/null)")" -- "$cur")'
59+ echo $' # shellcheck disable=SC2046 # intentional splitting for dynamic $(...) completions'
60+ echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter $(git branch --format=\' %(refname:short)\' 2>/dev/null))" -- "$cur")'
7061 echo $' ;;'
7162 echo $' '
7263 echo $' \' status\' *)'
64+ echo $' # shellcheck disable=SC2046 # intentional splitting for dynamic $(...) completions'
7365 echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "--help" "--verbose" "--branch" "-b")" -- "$cur")'
7466 echo $' ;;'
7567 echo $' '
7668 echo $' \' init\' *)'
69+ echo $' # shellcheck disable=SC2046 # intentional splitting for dynamic $(...) completions'
7770 echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_mygit_completions_filter "--bare")" -- "$cur")'
7871 echo $' ;;'
7972 echo $' '
8073 echo $' *)'
74+ echo $' # shellcheck disable=SC2046 # intentional splitting for dynamic $(...) completions'
8175 echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "-h" "-v" "--help" "--version" "init" "status")" -- "$cur")'
8276 echo $' ;;'
8377 echo $' '
0 commit comments