[java-common] 01/01: Improved the bash completion

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Sat Sep 26 07:03:17 UTC 2015


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to branch master
in repository java-common.

commit 131e8e5f43cfb2e4276cf3d1eaae2825ceb2e0e5
Author: Emmanuel Bourg <ebourg at apache.org>
Date:   Fri Sep 25 19:42:01 2015 +0200

    Improved the bash completion
---
 scripts/completion/update-java-alternatives | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/scripts/completion/update-java-alternatives b/scripts/completion/update-java-alternatives
index 7e5444a..80c00db 100644
--- a/scripts/completion/update-java-alternatives
+++ b/scripts/completion/update-java-alternatives
@@ -2,14 +2,13 @@
 # update-java-alternatives(8) completion
 #
 
-shopt -s dotglob
-
 #
 # List the available alternatives
 #
 _update-java-alternatives_list()
 {
-    prog=$(basename $0)
+    shopt -s dotglob
+
     top=/usr/lib/jvm
     for i in ${jinfo:-$top/*.jinfo}; do
         alias=$(basename ${i%.jinfo})
@@ -27,20 +26,26 @@ _update-java-alternatives()
 
     options=()
 
+    # complete but doesn't display the short options
+    if [[ $cur == "-s" || $cur == "-l" || $cur == "-a" || $cur == "-h" || $cur == "-v" ]] ; then
+        COMPREPLY=( $( compgen -W '$cur' -- $cur ) )
+        return 0
+    fi
+
     # suggest an action if none was specified yet
-    if [[ ! " ${COMP_WORDS[@]} " =~ " --set " ]]  && [[ ! " ${COMP_WORDS[@]} " =~ " -s " ]] && [[ 
-          ! " ${COMP_WORDS[@]} " =~ " --list " ]] && [[ ! " ${COMP_WORDS[@]} " =~ " -l " ]] && [[ 
-          ! " ${COMP_WORDS[@]} " =~ " --auto " ]] && [[ ! " ${COMP_WORDS[@]} " =~ " -a " ]] && [[ 
-          ! " ${COMP_WORDS[@]} " =~ " --help " ]] && [[ ! " ${COMP_WORDS[@]} " =~ " -h " ]]; then
+    if [[ ! "${COMP_WORDS[@]}" =~ " --set " ]]  && [[ ! "${COMP_WORDS[@]}" =~ " -s " ]] && [[
+          ! "${COMP_WORDS[@]}" =~ " --list " ]] && [[ ! "${COMP_WORDS[@]}" =~ " -l " ]] && [[
+          ! "${COMP_WORDS[@]}" =~ " --auto " ]] && [[ ! "${COMP_WORDS[@]}" =~ " -a " ]] && [[
+          ! "${COMP_WORDS[@]}" =~ " --help " ]] && [[ ! "${COMP_WORDS[@]}" =~ " -h " ]]; then
         options+=( --help --list --auto --set )
     fi
 
     # add the --set sub options
-    if [[ " ${COMP_WORDS[@]} " =~ " --set " ]] || [[ " ${COMP_WORDS[@]} " =~ " -s " ]] ; then
-        if [[ ! " ${COMP_WORDS[@]} " =~ " --verbose " ]] && [[ ! " ${COMP_WORDS[@]} " =~ " -v " ]]; then options+=("--verbose"); fi
-        if [[ ! " ${COMP_WORDS[@]} " =~ " --jre " ]]; then options+=("--jre"); fi
-        if [[ ! " ${COMP_WORDS[@]} " =~ " --jre-headless " ]]; then options+=("--jre-headless"); fi
-        if [[ ! " ${COMP_WORDS[@]} " =~ " --plugin " ]]; then options+=("--plugin"); fi
+    if [[ " ${COMP_WORDS[@]} " =~ " --set " ]] || [[ " ${COMP_WORDS[@]} " =~ " -s " ]]; then
+        if [[ ! "${COMP_WORDS[@]}" =~ " --verbose " ]] && [[ ! " ${COMP_WORDS[@]} " =~ " -v " ]]; then options+=("--verbose"); fi
+        if [[ ! "${COMP_WORDS[@]}" =~ " --plugin " ]]; then options+=("--plugin"); fi
+        if [[ ! "${COMP_WORDS[@]}" =~ " --jre " ]]; then options+=("--jre"); fi
+        if [[ ! "${COMP_WORDS[@]}" =~ " --jre-headless " ]]; then options+=("--jre-headless"); fi
     fi
 
     case "$prev" in

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/java-common.git



More information about the pkg-java-commits mailing list