Skip to content

Commit 9ddb44b

Browse files
committed
fix: avoid to use awk
Signed-off-by: wxiwnd <wxiwnd@outlook.com>
1 parent 56f66e2 commit 9ddb44b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

scripts/bash_pinyin_completion

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,17 @@ _pinyin_completion() {
8484
# merge result
8585
local -a old_candidates=("${COMPREPLY[@]}")
8686
COMPREPLY=("${old_candidates[@]}" "${pinyin_matched[@]}")
87-
mapfile -t COMPREPLY < <(printf "%s\n" "${COMPREPLY[@]}" | awk '!seen[$0]++')
87+
88+
# mapfile -t COMPREPLY < <(printf "%s\n" "${COMPREPLY[@]}" | awk '!seen[$0]++')
89+
declare -A seen
90+
local -a unique_compreply=()
91+
for item in "${COMPREPLY[@]}"; do
92+
if [[ -z "${seen[$item]}" ]]; then
93+
seen["$item"]=1
94+
unique_compreply+=( "$item" )
95+
fi
96+
done
97+
COMPREPLY=( "${unique_compreply[@]}" )
8898

8999
# fix space postfix
90100
if ((${#COMPREPLY[@]} == 1)) && [[ ${COMPREPLY[0]} != */ ]]; then

0 commit comments

Comments
 (0)