summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Bourg <ebourg@apache.org>2015-09-25 19:42:01 +0200
committerEmmanuel Bourg <ebourg@apache.org>2015-09-26 08:55:19 +0200
commit131e8e5f43cfb2e4276cf3d1eaae2825ceb2e0e5 (patch)
tree4ecaf9023f6c26f7a45ac16bfb5fcc07d8cd375a
parentb5b8cfafdf9d2743d9ee29b5fab49206d2c3155f (diff)
downloadjava-common-131e8e5f43cfb2e4276cf3d1eaae2825ceb2e0e5.tar.gz
Improved the bash completion
-rw-r--r--scripts/completion/update-java-alternatives29
1 files 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