Skip to content

Commit 1e85098

Browse files
committed
fix(script): ignore hostname (and other) completion req
Signed-off-by: wxiwnd <wxiwnd@outlook.com>
1 parent 0dac0c7 commit 1e85098

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

scripts/bash_pinyin_completion

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,29 @@ _comp_compgen__call_builtin() {
117117
local compgen_args=("$@")
118118

119119
# Check for file completion indicators
120-
for arg in "${compgen_args[@]}"; do
120+
local idx=0
121+
while [[ $idx -lt ${#compgen_args[@]} ]]; do
122+
local arg="${compgen_args[$idx]}"
121123
case "$arg" in
122-
-f|-d|-A|file|directory)
124+
-f|-d|-Afile|-Adirectory)
125+
is_file_completion=true
126+
break
127+
;;
128+
-A)
129+
if (( idx + 1 < ${#compgen_args[@]} )); then
130+
local next_arg="${compgen_args[$((idx + 1))]}"
131+
if [[ "$next_arg" == "file" || "$next_arg" == "directory" ]]; then
132+
is_file_completion=true
133+
break
134+
fi
135+
fi
136+
;;
137+
file|directory)
123138
is_file_completion=true
124139
break
125140
;;
126141
esac
142+
((idx++))
127143
done
128144

129145
# Also check if -W option is used with ${files[@]} or similar array expansion

0 commit comments

Comments
 (0)