Skip to content

Commit 81adc6c

Browse files
committed
fix(java,kldload): use _comp_compgen for filename-based mod names
1 parent 7920c9d commit 81adc6c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

completions/java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ _comp_cmd_java__classes()
8181
fi
8282

8383
elif [[ -d $i ]]; then
84-
COMPREPLY+=(
85-
$(compgen -d -- "$i/$cur" | command sed -e "s|^$i/\(.*\)|\1.|")
86-
$(compgen -f -X '!*.class' -- "$i/$cur" |
87-
command sed -e '/\$/d' -e "s|^$i/||")
88-
)
84+
local tmp
85+
_comp_compgen -v tmp -c "$i/$cur" -- -d -S .
86+
_comp_compgen -av tmp -c "$i/$cur" -- -f -X '!*.class'
87+
((${#tmp[@]})) &&
88+
_comp_compgen -a -- -X '*\$*' -W '"${tmp[@]#$i/}"'
8989
[[ ${COMPREPLY-} == *.class ]] || compopt -o nospace
9090

9191
# FIXME: if we have foo.class and foo/, the completion

completions/kldload

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ _comp_cmd_kldload()
1818

1919
compopt -o filenames
2020
for i in "${moddirs[@]}"; do
21-
modules=($(compgen -f "$i/$cur"))
22-
modules=(${modules[@]#$i/})
23-
COMPREPLY+=("${modules[@]}")
21+
_comp_compgen -v modules -c "$i/$cur" -- -f &&
22+
COMPREPLY+=("${modules[@]#$i/}")
2423
done
25-
COMPREPLY=(${COMPREPLY[@]%.ko})
24+
((${#COMPREPLY[@]})) &&
25+
COMPREPLY=("${COMPREPLY[@]%.ko}")
2626

2727
# also add dirs in current dir
2828
_comp_compgen -a filedir -d

0 commit comments

Comments
 (0)