From 81adc6ce741f69e936dfb0e1e891c372341814f2 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Tue, 30 May 2023 17:35:13 +0900 Subject: [PATCH] fix(java,kldload): use `_comp_compgen` for filename-based mod names --- completions/java | 10 +++++----- completions/kldload | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/completions/java b/completions/java index 526269b29e1..3494d7ebc8c 100644 --- a/completions/java +++ b/completions/java @@ -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 diff --git a/completions/kldload b/completions/kldload index be428a55061..d842b669c4d 100644 --- a/completions/kldload +++ b/completions/kldload @@ -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