Skip to content

Commit

Permalink
fix(java,kldload): use _comp_compgen for filename-based mod names
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed May 30, 2023
1 parent 7920c9d commit 81adc6c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions completions/java
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ _comp_cmd_java__classes()
fi

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

# FIXME: if we have foo.class and foo/, the completion
Expand Down
8 changes: 4 additions & 4 deletions completions/kldload
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ _comp_cmd_kldload()

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

# also add dirs in current dir
_comp_compgen -a filedir -d
Expand Down

0 comments on commit 81adc6c

Please sign in to comment.