[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-151-g1709686

Ville Skyttä ville.skytta at iki.fi
Thu Apr 28 18:46:03 UTC 2011


The following commit has been merged in the master branch:
commit e2c57c5966ca52b5b4d6fac88fcfa7e66d5e4887
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Thu Apr 28 21:21:31 2011 +0300

    Convert many completions to use _parse_help() instead of hardcoded option lists.

diff --git a/completions/_mock b/completions/_mock
index f082ac7..7c1afe5 100644
--- a/completions/_mock
+++ b/completions/_mock
@@ -63,13 +63,7 @@ _mock()
     $split && return 0
 
     if [[ "$cur" == -* ]] ; then
-        COMPREPLY=( $( compgen -W '--version --help --rebuild --buildsrpm
-            --shell --chroot --clean --init --installdeps --install --update
-            --orphanskill --copyin --copyout --root --offline --no-clean
-            --cleanup-after --no-cleanup-after --arch --target --define --with
-            --without --resultdir --uniqueext --configdir --rpmbuild_timeout
-            --unpriv --cwd --spec --sources --verbose --quiet --trace
-            --enable-plugin --disable-plugin --print-root-path' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
     else
         _filedir '@(?(no)src.r|s)pm'
     fi
diff --git a/completions/_yum b/completions/_yum
index 11b2512..029e765 100644
--- a/completions/_yum
+++ b/completions/_yum
@@ -139,11 +139,7 @@ _yum()
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--help --tolerant -C -c -R -d \
-            --showduplicates -e --quiet --verbose -y --version --installroot \
-            --enablerepo --disablerepo --exclude --disableexcludes --obsoletes \
-            --noplugins --nogpgcheck --disableplugin --enableplugin \
-            --skip-broken --color' -- $cur ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 } &&
diff --git a/completions/_yum-utils b/completions/_yum-utils
index b68edac..920c2db 100644
--- a/completions/_yum-utils
+++ b/completions/_yum-utils
@@ -13,8 +13,7 @@ _repomanage()
     [[ "$prev" == -@(h|-help|k|-keep) ]] && return 0
 
     if [[ "$cur" == -* ]] ; then
-        COMPREPLY=( $( compgen -W '--old --new --space \
-            --keep --nocheck --help' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
     else
         _filedir -d
     fi
diff --git a/completions/ant b/completions/ant
index 273c103..4a72965 100644
--- a/completions/ant
+++ b/completions/ant
@@ -30,11 +30,7 @@ _ant()
     esac
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-help -projecthelp -version -diagnostics \
-            -quiet -verbose -debug -emacs -lib -logfile -logger -listener \
-            -noinput -buildfile -D -keep-going -propertyfile -inputhandler \
-            -find -s -nice -nouserlib -noclasspath -autoproxy -main' \
-            -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
     else
         # available targets completion
         # find which buildfile to use
diff --git a/completions/bluez b/completions/bluez
index c97644a..953623b 100644
--- a/completions/bluez
+++ b/completions/bluez
@@ -58,7 +58,7 @@ _hcitool()
     _get_first_arg
     if [ -z $arg ]; then
         if [[ "$cur" == -* ]]; then
-            COMPREPLY=( $( compgen -W '--help -i' -- "$cur" ) )
+            COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         else
             COMPREPLY=( $( compgen -W 'dev inq scan name info \
                 spinq epinq cmd con cc dc sr cpt rssi lq tpl \
@@ -132,7 +132,7 @@ _sdptool()
     _get_first_arg
     if [ -z $arg ]; then
         if [[ "$cur" == -* ]]; then
-            COMPREPLY=( $( compgen -W '--help' -- "$cur" ) )
+            COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         else
             COMPREPLY=( $( compgen -W 'search browse records add \
                 del get setattr setseq' -- "$cur" ) )
@@ -213,8 +213,7 @@ _rfcomm()
     _get_first_arg
     if [ -z $arg ]; then
         if [[ "$cur" == -* ]]; then
-            COMPREPLY=( $( compgen -W '--help -a --raw \
-                --config -i --auth --encrypt --secure --master' -- "$cur" ) )
+            COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         else
             COMPREPLY=( $( compgen -W 'show connect listen watch \
                 bind release' -- "$cur" ) )
@@ -253,7 +252,7 @@ _ciptool()
     _get_first_arg
     if [ -z $arg ]; then
         if [[ "$cur" == -* ]]; then
-            COMPREPLY=( $( compgen -W '--help -i' -- "$cur" ) )
+            COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         else
             COMPREPLY=( $( compgen -W 'show search connect release \
                 loopback' -- "$cur" ) )
@@ -284,7 +283,7 @@ _dfutool()
     esac
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--help --device' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
     else
         local args
         _count_args
diff --git a/completions/configure b/completions/configure
index bca6777..cc69dd3 100644
--- a/completions/configure
+++ b/completions/configure
@@ -28,10 +28,7 @@ _configure()
             if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' )" \
             -- "$cur" ) )
     else
-        COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \
-            awk '/^  --[A-Za-z]/ { print $1; \
-            if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,=].*//g' )" \
-            -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
     fi
 } &&
 complete -F _configure configure
diff --git a/completions/coreutils b/completions/coreutils
index ef38bc4..c5c9795 100644
--- a/completions/coreutils
+++ b/completions/coreutils
@@ -102,8 +102,9 @@ _id()
     _init_completion || return
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-a -g --group -G --groups -n --name\
-            -r --real -u --user --help --version' -- "$cur" ) )
+        local opts=$( _parse_help "$1" )
+        [[ $opts ]] || opts="-G -g -u" # POSIX fallback
+        COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )
     else
         COMPREPLY=( $( compgen -u "$cur" ) )
     fi
@@ -133,8 +134,11 @@ _mktemp()
 
     $split && return 0
 
-    [[ "$cur" == -* ]] && \
-        COMPREPLY=( $( compgen -W '-d -u -q -p -t' -- "$cur" ) )
+    if [[ "$cur" == -* ]]; then
+        local opts=$( _parse_help "$1" )
+        [[ $opts ]] || opts="-d -u -q -p -t" # non-GNU fallback
+        COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )
+    fi
 } &&
 complete -F _mktemp mktemp
 
diff --git a/completions/cvs b/completions/cvs
index 07b681f..9c3cabf 100644
--- a/completions/cvs
+++ b/completions/cvs
@@ -29,14 +29,9 @@ _cvs_commands()
     cvs --help-commands 2>&1 | awk '/^(     *|\t)/ { print $1 }'
 }
 
-_cvs_options()
-{
-    cvs --help-options 2>&1 | awk '/^(     *|\t)-/ { print $1 }'
-}
-
 _cvs_command_options()
 {
-    cvs --help $1 2>&1 | sed -ne 's/^[[:space:]]*\(-[^[:space:]=[]*\).*/\1/p'
+    COMPREPLY=( $( compgen -W '$( _parse_help "$1" "--help $2" )' -- "$cur" ) )
 }
 
 _cvs_kflags()
@@ -166,8 +161,7 @@ _cvs()
                     COMPREPLY=( $( compgen -X '*~' -W '${files[@]}' -- $cur ) )
                 fi
             else
-                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
-                    -- "$cur" ) )
+                _cvs_command_options "$1" $mode
             fi
             ;;
         admin)
@@ -186,16 +180,14 @@ _cvs()
             esac
 
             if [[ "$cur" = -* ]]; then
-                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
-                    -- "$cur" ) )
+                _cvs_command_options "$1" $mode
             fi
             ;;
         annotate)
             [[ "$prev" == -@(r|D) ]] && return 0
 
             if [[ "$cur" = -* ]]; then
-                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
-                    -- "$cur" ) )
+                _cvs_command_options "$1" $mode
             else
                 get_entries
                 COMPREPLY=( $( compgen -W '${entries[@]}' -- "$cur" ) )
@@ -222,8 +214,7 @@ _cvs()
                     awk '{print $1}' ) )
                 COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
             else
-                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
-                    -- "$cur" ) )
+                _cvs_command_options "$1" $mode
             fi
             ;;
         commit)
@@ -258,8 +249,7 @@ _cvs()
                     COMPREPLY=( $(compgen -o default -- "$cur") )
                 fi
             else
-                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
-                    -- "$cur" ) )
+                _cvs_command_options "$1" $mode
             fi
             ;;
         cvsroot)
@@ -287,8 +277,7 @@ _cvs()
                 COMPREPLY=( $( cvs -d "$cvsroot" co -c | awk '{print $1}' ) )
                 COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
             else
-                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
-                    -- "$cur" ) )
+                _cvs_command_options "$1" $mode
             fi
             ;;
         diff)
@@ -311,8 +300,7 @@ _cvs()
                     COMPREPLY=( $(compgen -W '${miss[@]:-}' -- "$cur") )
                 fi
             else
-                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
-                    -- "$cur" ) )
+                _cvs_command_options "$1" $mode
             fi
             ;;
         import)
@@ -339,8 +327,7 @@ _cvs()
                 pwd=${pwd##*/}
                 COMPREPLY=( $( compgen -W '${COMPREPLY[@]} $pwd' -- $cur ) )
             else
-                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
-                    -- "$cur" ) )
+                _cvs_command_options "$1" $mode
             fi
             ;;
         update)
@@ -355,8 +342,7 @@ _cvs()
             esac
 
             if [[ "$cur" = -* ]]; then
-                COMPREPLY=( $( compgen -W "$( _cvs_command_options $mode )" \
-                    -- "$cur" ) )
+                _cvs_command_options "$1" $mode
             fi
             ;;
         "")
@@ -374,7 +360,8 @@ _cvs()
                     ;;
             esac
 
-            COMPREPLY=( $( compgen -W '$( _cvs_commands ) $( _cvs_options ) \
+            COMPREPLY=( $( compgen -W '$( _cvs_commands ) \
+                $( _parse_help "$1" --help-options ) \
                 --help --help-commands --help-options --version' -- "$cur" ) )
             ;;
     esac
diff --git a/completions/cvsps b/completions/cvsps
index e04aa4f..f22b7a4 100644
--- a/completions/cvsps
+++ b/completions/cvsps
@@ -50,10 +50,7 @@ _cvsps()
     esac
 
     if [[ "$cur" == -* ]] ; then
-        COMPREPLY=( $( compgen -W '-h -x -u -z -g -s -a -f -d -b -l -r -p -v \
-            -t --norc --summary-first --test-log --diff-opts --bkcvs --no-rlog \
-            --cvs-direct --no-cvs-direct --debuglvl -Z --root -q -A' \
-            -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) )
     else
         declare -F _cvs_roots &>/dev/null && _cvs_roots
     fi
diff --git a/completions/dd b/completions/dd
index cf11a1f..d6e9e87 100644
--- a/completions/dd
+++ b/completions/dd
@@ -23,7 +23,7 @@ _dd()
 
     _expand || return 0
 
-    COMPREPLY=( $( compgen -W '--help --version' -- "$cur" ) \
+    COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) \
                 $( compgen -W 'bs cbs conv count ibs if obs of seek skip' \
                            -S '=' -- "$cur" ) )
 } &&
diff --git a/completions/gkrellm b/completions/gkrellm
index fabd7ca..2b8cee8 100644
--- a/completions/gkrellm
+++ b/completions/gkrellm
@@ -35,10 +35,7 @@ _gkrellm()
     esac
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--theme --geometry --wm --m2 --nt \
-            --withdrawn --config --force-host-config --server --port --nc \
-            --config-clean --nolock --plugin --demo --logfile --version \
-            --debug-level --help' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
     fi
 
 } &&
diff --git a/completions/iconv b/completions/iconv
index c0216af..6002354 100644
--- a/completions/iconv
+++ b/completions/iconv
@@ -29,9 +29,7 @@ _iconv()
     $split && return 0
 
     if [[ "$cur" = -* ]]; then
-        COMPREPLY=( $( compgen -W '--from-code --to-code --list -c
-            --unicode-subst --byte-subst --widechar-subst --output --silent
-            --verbose --help --usage --version' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 } &&
diff --git a/completions/iftop b/completions/iftop
index f972d91..29b48cd 100644
--- a/completions/iftop
+++ b/completions/iftop
@@ -21,8 +21,7 @@ _iftop()
             ;;
     esac
 
-    COMPREPLY=( $( compgen -W '-h -n -N -p -P -b -B -i -f -F -c -m' \
-        -- "$cur" ) )
+    COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) )
 } &&
 complete -F _iftop iftop
 
diff --git a/completions/imagemagick b/completions/imagemagick
index 998f376..5f9f9ec 100644
--- a/completions/imagemagick
+++ b/completions/imagemagick
@@ -136,46 +136,7 @@ _convert()
     _ImageMagick
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-adaptive-blur -adaptive-resize \
-            -adaptive-sharpen -adjoin -affine -alpha -annotate \
-            -antialias -append -attenuate -authenticate \
-            -auto-orient -average -background -bench -bias \
-            -black-point-compensation -black-threshold \
-            -blue-primary -blur -border -bordercolor -caption \
-            -channel -charcoal -chop -clip -clip-mask -clip-path \
-            -clone -clut -coalesce -colorize -colors -colorspace \
-            -combine -comment -compose -composite -compress \
-            -contrast -contrast-stretch -convolve -crop -cycle \
-            -debug -decipher -deconstruct -define -delay -delete \
-            -density -depth -despeckle -display -dispose -distort \
-            -dither -draw -edge -emboss -encipher -encoding \
-            -endian -enhance -equalize -evaluate -extent -extract \
-            -family -fill -filter -flatten -flip -floodfill -flop \
-            -font -format -frame -fuzz -fx -gamma -gaussian-blur \
-            -geometry -gravity -green-primary -help -identify \
-            -implode -insert -intent -interlace -interpolate \
-            -label -lat -layers -level -limit -linear-stretch \
-            -liquid-rescale -list -log -loop -map -mask \
-            -mattecolor -median -modulate -monitor -monochrome \
-            -morph -mosaic -motion-blur -negate -noise -normalize \
-            -opaque -ordered-dither -orient -page -paint -ping \
-            -pointsize -polaroid -posterize -preview -print \
-            -process -profile -quality -quantize -quiet \
-            -radial-blur -raise -random-threshold -recolor \
-            -red-primary -regard-warnings -region -render -repage \
-            -resample -resize -respect-parenthesis -reverse -roll \
-            -rotate -sample -sampling-factor -scale -scene -seed \
-            -segment -separate -sepia-tone -set -shade -shadow \
-            -sharpen -shave -shear -sigmoidal-contrast -size \
-            -sketch -solarize -splice -spread -stretch -strip \
-            -stroke -strokewidth -style -swap -swirl -taint \
-            -texture -threshold -thumbnail -tile -tile-offset \
-            -tint -transform -transparent -transparent-color \
-            -transpose -transverse -treedepth -trim -type \
-            -undercolor -unique-colors -units -unsharp -verbose \
-            -version -view -vignette -virtual-pixel -wave \
-            -weight -white-point -white-threshold \
-            -write' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) )
     elif [[ "$cur" == +* ]]; then
         COMPREPLY=( $( compgen -W '+adjoin +append +compress \
             +contrast +debug +dither +endian +gamma +label +map \
@@ -195,42 +156,7 @@ _mogrify()
     _ImageMagick
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-adaptive-blur -adaptive-resize \
-            -adaptive-sharpen -adjoin -affine -alpha -annotate \
-            -antialias -attenuate -authenticate -auto-orient \
-            -background -bias -black-point-compensation \
-            -black-threshold -blue-primary -blur -border \
-            -bordercolor -caption -channel -charcoal -chop -clip \
-            -clip-mask -clip-path -clut -colorize -colors \
-            -colorspace -comment -compose -compress -contrast \
-            -contrast-stretch -convolve -cycle -debug -decipher \
-            -define -delay -density -depth -despeckle -display \
-            -dispose -distort -dither -draw -edge -emboss \
-            -encipher -encoding -endian -enhance -equalize \
-            -evaluate -extent -extract -family -fill -filter \
-            -flip -floodfill -flop -font -format -frame -fuzz \
-            -gamma -gaussian-blur -geometry -gravity \
-            -green-primary -help -identify -implode -intent \
-            -interlace -interpolate -label -lat -layers -level \
-            -limit -linear-stretch -liquid-rescale -list -log \
-            -loop -mask -mattecolor -median -modulate -monitor \
-            -monochrome -motion-blur -negate -noise -normalize \
-            -opaque -ordered-dither -orient -page -paint -path \
-            -ping -pointsize -polaroid -posterize -preview -print \
-            -profile -quality -quantize -quiet -radial-blur \
-            -raise -random-threshold -recolor -red-primary \
-            -regard-warnings -region -render -repage -resample \
-            -resize -roll -rotate -sample -sampling-factor -scale \
-            -scene -seed -segment -sepia-tone -set -shade -shadow \
-            -sharpen -shave -shear -sigmoidal-contrast -size \
-            -sketch -solarize -splice -spread -stretch -strip \
-            -stroke -strokewidth -style -swirl -taint -texture \
-            -threshold -thumbnail -tile -tile-offset -tint \
-            -transform -transparent -transparent-color -transpose \
-            -transverse -treedepth -trim -type -undercolor \
-            -unique-colors -units -unsharp -verbose -version \
-            -view -vignette -virtual-pixel -wave -weight \
-            -white-point -white-threshold' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) )
     elif [[ "$cur" == +* ]]; then
         COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither \
             +endian +gamma +label +map +mask +matte +negate +page \
@@ -249,26 +175,7 @@ _display()
     _ImageMagick
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-alpha -antialias -authenticate \
-            -auto-orient -backdrop -background -border \
-            -bordercolor -borderwidth -channel -clip \
-            -clip-path -coalesce -colormap -colors -colorspace \
-            -comment -compress -contrast -crop -debug -decipher \
-            -define -delay -density -depth -despeckle -display \
-            -dispose -dither -edge -endian -enhance -extract \
-            -filter -flatten -flip -flop -font -foreground \
-            -format -frame -gamma -geometry -help -iconGeometry \
-            -iconic -identify -immutable -interlace -interpolate \
-            -label -limit -list -log -loop -map -mattecolor \
-            -monitor -monochrome -name -negate -page -profile \
-            -quality -quantize -quiet -raise -regard-warnings \
-            -remote -repage -resample -resize \
-            -respect-parenthesis -roll -rotate -sample \
-            -sampling-factor -scenes -seed -segment -set \
-            -shared-memory -sharpen -size -strip -texture -title \
-            -transparent-color -treedepth -trim -update \
-            -usePixmap -verbose -version -virtual-pixel -visual \
-            -window -window-group -write' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) )
     elif [[ "$cur" == +* ]]; then
         COMPREPLY=( $( compgen -W '+compress +contrast +debug +dither \
             +endian +gamma +label +map +matte +negate +page \
@@ -287,21 +194,7 @@ _animate()
     _ImageMagick
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-alpha -authenticate -backdrop \
-            -background -bordercolor -borderwidth -channel \
-            -coalesce -colormap -colors -colorspace -crop -debug \
-            -decipher -define -delay -density -depth -display \
-            -dispose -dither -extract -filter -flatten -font \
-            -foreground -format -gamma -geometry -help \
-            -iconGeometry -iconic -identify -immutable -interlace \
-            -interpolate -limit -list -log -loop -map -mattecolor \
-            -mattecolor -monitor -monochrome -name -page -pause \
-            -quantize -quiet -regard-warnings -remote -repage \
-            -resample -resize -respect-parenthesis -rotate \
-            -sampling-factor -scenes -seed -set -shared-memory \
-            -size -strip -title -transparent-color -treedepth \
-            -trim -verbose -version -virtual-pixel -visual \
-            -window' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) )
     elif [[ "$cur" == +* ]]; then
         COMPREPLY=( $( compgen -W '+debug +dither +gamma +map +matte' \
             -- "$cur" ) )
@@ -319,13 +212,7 @@ _identify()
     _ImageMagick
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-alpha -antialias -authenticate \
-            -channel -colorspace -crop -debug -define -density \
-            -depth -extract -format -fuzz -gamma -help -interlace \
-            -interpolate -limit -list -log -monitor -ping -quiet \
-            -regard-warnings -respect-parenthesis \
-            -sampling-factor -seed -set -size -strip -units \
-            -verbose -version -virtual-pixel' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) )
     elif [[ "$cur" == +* ]]; then
         COMPREPLY=( $( compgen -W '+debug' -- "$cur" ) )
     else
@@ -342,25 +229,7 @@ _montage()
     _ImageMagick
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-adjoin -affine -alpha \
-            -authenticate -background -blue-primary -blur -border \
-            -bordercolor -borderwidth -caption -channel -clone \
-            -coalesce -colors -colorspace -comment -compose \
-            -compress -crop -debug -define -density -depth \
-            -display -dispose -dither -draw -encoding -endian \
-            -extract -fill -filter -flatten -flip -flop -font \
-            -format -frame -gamma -geometry -gravity \
-            -green-primary -help -identify -interlace \
-            -interpolate -label -limit -list -log -mattecolor \
-            -mode -monitor -monochrome -origin -page -pointsize \
-            -polaroid -profile -quality -quantize -quiet \
-            -red-primary -regard-warnings -repage -resize \
-            -respect-parenthesis -rotate -sampling-factor -scenes \
-            -seed -set -shadow -size -strip -stroke -texture \
-            -thumbnail -tile -title -transform -transparent \
-            -transparent-color -treedepth -trim -type -units \
-            -verbose -version -virtual-pixel \
-            -white-point' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) )
     elif [[ "$cur" == +* ]]; then
         COMPREPLY=( $( compgen -W '+adjoin +compress +debug +dither \
             +endian +gamma +label +matte +page' -- "$cur" ) )
@@ -378,22 +247,7 @@ _composite()
     _ImageMagick
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-affine -alpha -authenticate \
-            -blend -blue-primary -border -bordercolor -channel \
-            -colors -colorspace -comment -compose -compress \
-            -debug -decipher -define -density -depth -displace \
-            -display -dispose -dissolve -dither -encipher \
-            -encoding -endian -extract -filter -font -format \
-            -geometry -gravity -green-primary -help -identify \
-            -interlace -interpolate -label -limit -list -log \
-            -monitor -monochrome -negate -page -profile -quality \
-            -quantize -quiet -red-primary -regard-warnings \
-            -repage -resize -respect-parenthesis -rotate \
-            -sampling-factor -scene -seed -sharpen -shave -size \
-            -stegano -stereo -strip -swap -thumbnail -tile \
-            -transform -transparent-color -treedepth -type -units \
-            -unsharp -verbose -version -virtual-pixel -watermark \
-            -white-point -write' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) )
     elif [[ "$cur" == +* ]]; then
         COMPREPLY=( $( compgen -W '+compress +debug +dither +endian +label \
             +matte +negate +page +write' -- "$cur" ) )
@@ -411,15 +265,7 @@ _compare()
     _ImageMagick
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-alpha -authenticate -channel \
-            -colorspace -compress -debug -decipher -define \
-            -density -depth -encipher -extract -format -fuzz \
-            -help -highlight-color -identify -interlace -limit \
-            -list -log -metric -monitor -passphrase -profile \
-            -quality -quantize -quiet -regard-warnings \
-            -respect-parenthesis -sampling-factor -seed -set \
-            -size -transparent-color -type -verbose -version \
-            -virtual-pixel' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) )
     elif [[ "$cur" == +* ]]; then
         COMPREPLY=( $( compgen -W '+debug' -- "$cur" ) )
     else
@@ -436,8 +282,7 @@ _conjure()
     _ImageMagick
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-debug -help -list -log -monitor -quiet \
-            -regard-warnings -seed -verbose -version' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) )
     elif [[ "$cur" == +* ]]; then
         COMPREPLY=( $( compgen -W '+debug' -- "$cur" ) )
     else
@@ -454,19 +299,7 @@ _import()
     _ImageMagick
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-adjoin -annotate -border -channel \
-            -colors -colorspace -comment -compress -crop -debug \
-            -define -delay -density -depth -descend -display \
-            -dispose -dither -encipher -encoding -endian -filter \
-            -format -frame -geometry -gravity -help -identify \
-            -interlace -interpolate -label -limit -list -log \
-            -monitor -monochrome -negate -page -pause -pointsize \
-            -quality -quantize -quiet -regard-warnings -repage \
-            -resize -respect-parenthesis -rotate -sampling-factor \
-            -scene -screen -seed -set -silent -snaps -strip \
-            -thumbnail -transparent -transparent-color -treedepth \
-            -trim -type -verbose -version -virtual-pixel \
-            -window' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) )
     elif [[ "$cur" == +* ]]; then
         COMPREPLY=( $( compgen -W '+debug' -- "$cur" ) )
     else
@@ -483,13 +316,7 @@ _stream()
     _ImageMagick
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-authenticate -channel -colorspace \
-            -compress -debug -define -density -depth -extract \
-            -help -identify -interlace -interpolate -limit -list \
-            -log -map -monitor -quantize -quiet -regard-warnings \
-            -respect-parenthesis -sampling-factor -seed -set \
-            -size -storage-type -transparent-color -verbose \
-            -version -virtual-pixel' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) )
     elif [[ "$cur" == +* ]]; then
         COMPREPLY=( $( compgen -W '+debug' -- "$cur" ) )
     else
diff --git a/completions/java b/completions/java
index f36fb7b..7a2d7b8 100644
--- a/completions/java
+++ b/completions/java
@@ -215,11 +215,7 @@ _java()
     esac
 
     if [[ "$cur" == -* ]]; then
-        # standard options
-        COMPREPLY=( $( compgen -W '-client -server -agentlib: -agentpath:
-            -classpath -D -d32 -d64 -enableassertions -disableassertions
-            -enablesystemassertions -disablesystemassertions -jar -javaagent:
-            -verbose -verbose -version -showversion -help -X' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) )
     else
         if [[ "$prev" == -jar ]]; then
             # jar file completion
@@ -263,20 +259,7 @@ _javadoc()
     esac
 
     if [[ "$cur" == -* ]]; then
-        # relevant options completion
-        COMPREPLY=( $( compgen -W '-overview -public -protected \
-            -package -private -help -doclet -docletpath \
-            -sourcepath -classpath -exclude -subpackages \
-            -breakiterator -bootclasspath -source -extdirs \
-            -verbose -locale -encoding -J -d -use -version \
-            -author -docfilessubdirs -splitindex \
-            -windowtitle -doctitle -header -footer -bottom \
-            -link -linkoffline -excludedocfilessubdir \
-            -group -nocomment -nodeprecated -noqualifier \
-            -nosince -nodeprecatedlist -notree -noindex \
-            -nohelp -nonavbar -quiet -serialwarn -tag \
-            -taglet -tagletpath -charset -helpfile \
-            -linksource -stylesheetfile -docencoding' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) )
     else
         # source files completion
         _filedir java
@@ -304,11 +287,7 @@ _javac()
     esac
 
     if [[ "$cur" == -* ]]; then
-        # relevant options completion
-        COMPREPLY=( $( compgen -W '-g -g:none -g:lines -g:vars \
-            -g:source -O -nowarn -verbose -deprecation -classpath \
-            -sourcepath -bootclasspath -extdirs -d -encoding -source \
-            -target -help' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" -help )' -- "$cur" ) )
     else
         # source files completion
         _filedir java
diff --git a/completions/lftp b/completions/lftp
index c3eac68..18944bc 100644
--- a/completions/lftp
+++ b/completions/lftp
@@ -17,8 +17,7 @@ _lftp()
     esac
 
     if [[ "$cur" == -* ]] ; then
-        COMPREPLY=( $( compgen -W '-f -c --help --version -e -u -p' \
-            -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 
diff --git a/completions/lrzip b/completions/lrzip
index 77e42d0..eb9d0f3 100644
--- a/completions/lrzip
+++ b/completions/lrzip
@@ -8,8 +8,7 @@ _lrzip()
     _init_completion || return
 
     if [[ "$cur" == -* && $prev != -N ]]; then
-        COMPREPLY=( $( compgen -W '-w -d -o -O -S -f -D -q -L -n -l -b -g -M \
-            -T -N -v -vv -V -h' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 
diff --git a/completions/net-tools b/completions/net-tools
index 55dfa84..2f21643 100644
--- a/completions/net-tools
+++ b/completions/net-tools
@@ -25,8 +25,7 @@ _mii_tool()
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--verbose --version --reset --restart \
-            --watch --log --advertise --force' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
     else
         _available_interfaces -a
     fi
@@ -54,10 +53,7 @@ _mii_diag()
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--advertise --fixed-speed --all-interfaces \
-            --status --debug --read-parameters --set-parameters --msg-level \
-            --phy --restart --reset --verbose --version --watch --help' \
-            -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
     else
         _available_interfaces -a
     fi
diff --git a/completions/pkg-config b/completions/pkg-config
index ff665c2..97a0912 100644
--- a/completions/pkg-config
+++ b/completions/pkg-config
@@ -25,16 +25,7 @@ _pkg_config()
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        # return list of available options
-        COMPREPLY=( $( compgen -W '--version --modversion \
-            --atleast-pkgconfig-version --libs --static \
-            --short-errors --libs-only-l --libs-only-other \
-            --libs-only-L --cflags --cflags-only-I \
-            --cflags-only-other --variable --define-variable \
-            --exists --uninstalled --atleast-version \
-            --exact-version --max-version --list-all --debug \
-            --print-errors --silence-errors --errors-to-stdout \
-            --print-provides --print-requires --help --usage' -- "$cur") )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
     else
         COMPREPLY=( $( compgen -W "$( pkg-config --list-all \
             2>/dev/null | awk '{print $1}' )" -- "$cur" ) )
diff --git a/completions/reptyr b/completions/reptyr
index 4d1a9c4..527735b 100644
--- a/completions/reptyr
+++ b/completions/reptyr
@@ -14,7 +14,7 @@ _reptyr()
     esac
 
     if [[ $cur == -* ]]; then
-        COMPREPLY=( $( compgen -W '-l -s' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 
diff --git a/completions/rtcwake b/completions/rtcwake
index 24cd9c1..b204f93 100644
--- a/completions/rtcwake
+++ b/completions/rtcwake
@@ -27,8 +27,7 @@ _rtcwake()
 
     $split && return 0
 
-    COMPREPLY=( $( compgen -W '--device --local --mode --seconds --time --utc \
-        --verbose --version --help' -- "$cur" ) )
+    COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
 } &&
 complete -F _rtcwake rtcwake
 
diff --git a/completions/shadow b/completions/shadow
index 31ed80d..b89ba16 100644
--- a/completions/shadow
+++ b/completions/shadow
@@ -40,11 +40,7 @@ _useradd()
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--base-dir --comment --home-dir --defaults \
-            --expiredate --inactive --gid --groups --help --skel --key \
-            --no-log-init --create-home --no-create-home --no-user-group \
-            --non-unique --password --system --shell --uid --user-group \
-            --selinux-user' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 } &&
@@ -87,10 +83,7 @@ _usermod()
 
     if [[ "$cur" == -* ]]; then
         # TODO: -U/--unlock, -p/--password, -L/--lock mutually exclusive
-        COMPREPLY=( $( compgen -W '--append --comment --home --expiredate \
-            --inactive --gid --groups --help --login --lock --move-home \
-            --non-unique --password --shell --uid --unlock --selinux-user' \
-            -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 
@@ -105,7 +98,7 @@ _userdel()
     _init_completion || return
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--force --help --remove' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 
@@ -132,8 +125,7 @@ _chage()
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--lastday --expiredate --help --inactive \
-            --list --mindays --maxdays --warndays' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 
@@ -186,8 +178,7 @@ _chpasswd()
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--crypt-method --encrypted \
-            --help --md5 --sha-rounds' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 } &&
@@ -216,8 +207,7 @@ _newusers()
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--crypt-method --help --system \
-            --sha-rounds' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 
@@ -261,8 +251,7 @@ _groupadd()
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--force --gid --help \
-            --key --non-unique --password --system' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 } &&
@@ -289,8 +278,7 @@ _groupmod()
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--gid --help --new-name \
-            --non-unique --password' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 
@@ -321,14 +309,15 @@ _gpasswd()
     _init_completion || return
 
     case $prev in
-        -a|-d|-A|-M)
+        -a|--add|-d|--delete|-A|--administrators|-M|--members)
             COMPREPLY=( $( compgen -u -- "$cur" ) )
             return 0
             ;;
     esac
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-a -d -r -R -A -M' -- "$cur" ) )
+        # TODO: only -A and -M can be combined
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 
@@ -343,18 +332,18 @@ _groupmems()
     _init_completion || return
 
     case $prev in
-        -a|-d)
+        -a|--add|-d|--delete)
             COMPREPLY=( $( compgen -u -- "$cur" ) )
             return 0
             ;;
-        -g)
+        -g|--group)
             COMPREPLY=( $( compgen -g -- "$cur" ) )
             return 0
             ;;
     esac
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-a -d -p -g -l' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 } &&
@@ -388,8 +377,7 @@ _vipw()
     esac
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--group --help --passwd \
-            --quiet --shadow' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 } &&
@@ -417,8 +405,7 @@ _faillog()
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--all --help --lock-time \
-            --maximum --reset --time --user' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 } &&
@@ -446,7 +433,7 @@ _lastlog()
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--before --help --time --user' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 } &&
diff --git a/completions/wol b/completions/wol
index 107cba5..7a26833 100644
--- a/completions/wol
+++ b/completions/wol
@@ -31,8 +31,7 @@ _wol()
     $split && return 0
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--help --version --verbose --wait --host
-            --port --file --passwd' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 
diff --git a/completions/xrdb b/completions/xrdb
index b42320f..8170c1c 100644
--- a/completions/xrdb
+++ b/completions/xrdb
@@ -18,9 +18,7 @@ _xrdb()
     esac
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '-help -display -all -global -screen -screens
-            -n -quiet -cpp -nocpp -symbols -query -load -override -merge
-            -remove -retain -edit -backup' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 
diff --git a/completions/xz b/completions/xz
index 28d0e48..70dadd8 100644
--- a/completions/xz
+++ b/completions/xz
@@ -10,12 +10,8 @@ _xz()
     _split_longopt && split=true
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--compress --decompress --test --list \
-            --keep --force --stdout --no-sparse --suffix --files --files0 \
-            --format --check -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 --extreme --memory \
-            --lzma1 --lzma2 --x86 --powerpc --ia64 --arm --armthumb --sparc \
-            --delta --quiet --verbose --no-warn --robot --info-memory --help \
-            --long-help --version' -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" --long-help ) {-1..-9}' \
+            -- "$cur" ) )
         return 0
     fi
 
@@ -67,8 +63,7 @@ _xzdec()
     _init_completion -n = || return
 
     if [[ "$cur" == -* ]]; then
-        COMPREPLY=( $( compgen -W '--memory --quiet --help --version' \
-            -- "$cur" ) )
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
         return 0
     fi
 
diff --git a/test/lib/completions/display.exp b/test/lib/completions/display.exp
index e9fe766..70cea18 100644
--- a/test/lib/completions/display.exp
+++ b/test/lib/completions/display.exp
@@ -17,22 +17,7 @@ assert_complete_any "display "
 sync_after_int
 
 
-set test "- should complete options"
-set options {
-    -alpha -antialias -authenticate -auto-orient -backdrop -background -border
-    -bordercolor -borderwidth -channel -clip -clip-path -coalesce -colormap
-    -colors -colorspace -comment -compress -contrast -crop -debug -decipher
-    -define -delay -density -depth -despeckle -display -dispose -dither -edge
-    -endian -enhance -extract -filter -flatten -flip -flop -font -foreground
-    -format -frame -gamma -geometry -help -iconGeometry -iconic -identify
-    -immutable -interlace -interpolate -label -limit -list -log -loop -map
-    -mattecolor -monitor -monochrome -name -negate -page -profile -quality
-    -quantize -quiet -raise -regard-warnings -remote -repage -resample -resize
-    -respect-parenthesis -roll -rotate -sample -sampling-factor -scenes -seed
-    -segment -set -shared-memory -sharpen -size -strip -texture -title
-    -transparent-color -treedepth -trim -update -usePixmap -verbose -version
-    -virtual-pixel -visual -window -window-group -write }
-assert_complete $options "display -" $test
+assert_complete_any "display -"
 
 
 sync_after_int

-- 
bash-completion



More information about the Bash-completion-commits mailing list