Include trailing equals sign in options that take arguments that way.

This way it's clearer to users that an argument is expected.  It's
likely that this commit does not catch all such cases, but it should
do it for most of the affected commands I have installed.
This commit is contained in:
Ville Skyttä 2011-05-02 11:41:52 +03:00
parent 0a84ad771d
commit c875723bef
33 changed files with 103 additions and 57 deletions

View File

@ -774,11 +774,13 @@ _parse_help()
# Expand --[no]foo to --foo and --nofoo # Expand --[no]foo to --foo and --nofoo
if [[ $option == *\[no\]?* ]]; then if [[ $option == *\[no\]?* ]]; then
option2=${option/\[no\]/} option2=${option/\[no\]/}
printf '%s\n' "${option2%%[=<{[]*}" option2=${option2%%[<{[]*}
printf '%s\n' "${option2/=*/=}"
option=${option/\[no\]/no} option=${option/\[no\]/no}
fi fi
printf '%s\n' "${option%%[=<{[]*}" option=${option%%[<{[]*}
printf '%s\n' "${option/=*/=}"
done done
} }
@ -1678,8 +1680,9 @@ _longopt()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \ COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \
sed -ne 's/.*\(--[-A-Za-z0-9]\{1,\}\).*/\1/p' | sort -u )" \ sed -ne 's/.*\(--[-A-Za-z0-9]\{1,\}=\?\).*/\1/p' | sort -u )" \
-- "$cur" ) ) -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
elif [[ "$1" == @(mk|rm)dir ]]; then elif [[ "$1" == @(mk|rm)dir ]]; then
compopt +o default compopt +o default
_filedir -d _filedir -d

View File

@ -61,6 +61,7 @@ _mock()
if [[ "$cur" == -* ]] ; then if [[ "$cur" == -* ]] ; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else else
_filedir '@(?(no)src.r|s)pm' _filedir '@(?(no)src.r|s)pm'
fi fi

View File

@ -137,6 +137,7 @@ _yum()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi
} && } &&

View File

@ -60,27 +60,28 @@ _aspell()
$split && return 0 $split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--conf --conf-dir --data-dir --dict-dir \ COMPREPLY=( $( compgen -W '--conf= --conf-dir= --data-dir= --dict-dir= \
--encoding --add-filter --rem-filter --mode \ --encoding= --add-filter= --rem-filter= --mode= \
--add-extra-dicts --rem-extra-dicts \ --add-extra-dicts= --rem-extra-dicts= \
--home-dir --ignore --ignore-accents \ --home-dir= --ignore= --ignore-accents \
--dont-ignore-accents --ignore-case --dont-ignore-case \ --dont-ignore-accents --ignore-case --dont-ignore-case \
--ignore-repl --dont-ignore-repl --jargon --keyboard \ --ignore-repl --dont-ignore-repl --jargon --keyboard= \
--lang --language-tag --local-data-dir --master \ --lang= --language-tag --local-data-dir= --master= \
--module --add-module-search-order \ --module --add-module-search-order \
--rem-module-search-order --per-conf --personal \ --rem-module-search-order --per-conf= --personal= \
--prefix --repl --run-together --dont-run-together \ --prefix= --repl= --run-together --dont-run-together \
--run-together-limit --run-together-min --save-repl \ --run-together-limit= --run-together-min= --save-repl \
--dont-save-repl --set-prefix --dont-set-prefix --size \ --dont-save-repl --set-prefix --dont-set-prefix --size= \
--spelling --strip-accents --dont-strip-accents \ --spelling --strip-accents --dont-strip-accents \
--sug-mode --add-word-list-path --rem-word-list-path \ --sug-mode= --add-word-list-path --rem-word-list-path \
--backup --dont-backup --reverse --dont-reverse \ --backup --dont-backup --reverse --dont-reverse \
--time --dont-time --keymapping --add-email-quote \ --time --dont-time --keymapping= --add-email-quote= \
--rem-email-quote --email-margin --add-tex-command \ --rem-email-quote= --email-margin= --add-tex-command= \
--rem-tex-command --tex-check-comments \ --rem-tex-command= --tex-check-comments \
--dont-tex-check-comments --add-tex-extension \ --dont-tex-check-comments --add-tex-extension \
--rem-tex-extension --add-sgml-check --rem-sgml-check \ --rem-tex-extension --add-sgml-check= --rem-sgml-check= \
--add-sgml-extension --rem-sgml-extension' -- "$cur" ) ) --add-sgml-extension --rem-sgml-extension' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else else
COMPREPLY=( $( compgen -W 'usage help check pipe list \ COMPREPLY=( $( compgen -W 'usage help check pipe list \
config soundslike filter version dump create merge' -- "$cur" ) ) config soundslike filter version dump create merge' -- "$cur" ) )

View File

@ -30,6 +30,7 @@ _autoconf()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return return
fi fi
@ -64,6 +65,7 @@ _autoreconf()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi
@ -95,6 +97,7 @@ _autoscan()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi

View File

@ -26,6 +26,7 @@ _automake()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return return
fi fi
@ -62,6 +63,7 @@ _aclocal()
$split && return 0 $split && return 0
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
} && } &&
complete -F _aclocal aclocal aclocal-1.11 complete -F _aclocal aclocal aclocal-1.11

View File

@ -33,8 +33,10 @@ _configure()
awk '/^ --[A-Za-z]/ { print $1; \ awk '/^ --[A-Za-z]/ { print $1; \
if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' )" \ if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' )" \
-- "$cur" ) ) -- "$cur" ) )
[[ $COMPREPLY == *=* ]] && compopt -o nospace
else else
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
fi fi
} && } &&
complete -F _configure configure complete -F _configure configure

View File

@ -129,6 +129,7 @@ _mktemp()
local opts=$( _parse_help "$1" ) local opts=$( _parse_help "$1" )
[[ $opts ]] || opts="-d -u -q -p -t" # non-GNU fallback [[ $opts ]] || opts="-d -u -q -p -t" # non-GNU fallback
COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
fi fi
} && } &&
complete -F _mktemp mktemp complete -F _mktemp mktemp

View File

@ -33,6 +33,7 @@ _cryptsetup()
if [ -z $arg ]; then if [ -z $arg ]; then
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else else
COMPREPLY=( $( compgen -W 'create remove status resize luksFormat \ COMPREPLY=( $( compgen -W 'create remove status resize luksFormat \
luksOpen luksClose luksSuspend luksResume luksAddKey \ luksOpen luksClose luksSuspend luksResume luksAddKey \

View File

@ -283,6 +283,7 @@ _cvs()
diff) diff)
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
_cvs_command_options "$1" $mode _cvs_command_options "$1" $mode
[[ $COMPREPLY == *= ]] && compopt -o nospace
else else
get_entries get_entries
COMPREPLY=( $( compgen -W '${entries[@]:-}' -- "$cur" ) ) COMPREPLY=( $( compgen -W '${entries[@]:-}' -- "$cur" ) )

View File

@ -58,12 +58,12 @@ _dpkg()
COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) ) COMPREPLY=( $( _comp_dpkg_installed_packages "$cur" ) )
return 0 return 0
;; ;;
*)
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
;;
esac esac
$split && return
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
} && } &&
complete -F _dpkg dpkg dpkg-deb complete -F _dpkg dpkg dpkg-deb
} }

View File

@ -68,6 +68,7 @@ _getent()
if [[ $cur == -* ]]; then if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
elif [[ -z $db ]]; then elif [[ -z $db ]]; then
COMPREPLY=( $( compgen -W 'passwd group hosts services protocols \ COMPREPLY=( $( compgen -W 'passwd group hosts services protocols \
networks ahosts ahostsv4 ahostsv6 aliases ethers netgroup rpc \ networks ahosts ahostsv4 ahostsv6 aliases ethers netgroup rpc \

View File

@ -16,6 +16,7 @@ _gzip()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) {-1..-9}' \ COMPREPLY=( $( compgen -W '$( _parse_help "$1" ) {-1..-9}' \
-- "$cur" ) ) -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi

View File

@ -27,6 +27,7 @@ _iconv()
if [[ "$cur" = -* ]]; then if [[ "$cur" = -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi
} && } &&

View File

@ -33,6 +33,7 @@ _info()
if [[ $cur == -* ]]; then if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return return
fi fi

View File

@ -493,7 +493,7 @@ have javaws &&
_javaws() _javaws()
{ {
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion -n = || return
case $prev in case $prev in
-help|-license|-about|-viewer|-arg|-param|-property|-update|-umask) -help|-license|-about|-viewer|-arg|-param|-property|-update|-umask)
@ -509,8 +509,11 @@ _javaws()
;; ;;
esac esac
if [[ $cur == -* ]]; then if [[ $cur == *= ]]; then
return 0
elif [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W "$( _parse_help "$1" -help ) " -- "$cur" ) ) COMPREPLY=( $( compgen -W "$( _parse_help "$1" -help ) " -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi

View File

@ -40,6 +40,7 @@ _k3b()
if [[ "$cur" == -* ]] ; then if [[ "$cur" == -* ]] ; then
COMPREPLY=( $( compgen -W "$( _parse_help "$1" )" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$( _parse_help "$1" )" -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else else
_filedir _filedir
fi fi

View File

@ -42,6 +42,7 @@ _man()
if [[ $cur == -* ]]; then if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return return
fi fi

View File

@ -27,6 +27,7 @@ _mc()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help-all )' \ COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help-all )' \
-- "$cur" ) ) -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else else
_filedir -d _filedir -d
fi fi

View File

@ -102,7 +102,7 @@ _mdadm()
local options local options
options='--help --help-options --version --verbose --quiet \ options='--help --help-options --version --verbose --quiet \
--brief --force --config --scan --metadata --homehost' --brief --force --config= --scan --metadata= --homehost='
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
if [[ $cword -eq 1 ]] ; then if [[ $cword -eq 1 ]] ; then
@ -111,18 +111,18 @@ _mdadm()
else else
case ${words[cword-1]} in case ${words[cword-1]} in
-A|--assemble) -A|--assemble)
COMPREPLY=( $( compgen -W "$options --uuid \ COMPREPLY=( $( compgen -W "$options --uuid= \
--super-minor --name --force --run \ --super-minor= --name= --force --run \
--no-degraded --auto --bitmap --backup-file \ --no-degraded --auto= --bitmap= --backup-file= \
--update --auto-update-homehost" -- "$cur" ) ) --update= --auto-update-homehost" -- "$cur" ) )
;; ;;
-B|-C|-G|--build|--create|--grow) -B|-C|-G|--build|--create|--grow)
COMPREPLY=( $( compgen -W "$options --raid-devices \ COMPREPLY=( $( compgen -W "$options --raid-devices= \
--spare-devices --size --chunk --rounding \ --spare-devices= --size= --chunk= --rounding= \
--level --layout --parity --bitmap \ --level= --layout= --parity= --bitmap= \
--bitmap-chunk --write-mostly --write-behind \ --bitmap-chunk= --write-mostly --write-behind= \
--assume-clean --backup-file --name --run \ --assume-clean --backup-file= --name= --run \
--force --auto" -- "$cur" ) ) --force --auto=" -- "$cur" ) )
;; ;;
-F|--follow|--monitor) -F|--follow|--monitor)
COMPREPLY=( $( compgen -W "$options --mail --program \ COMPREPLY=( $( compgen -W "$options --mail --program \
@ -142,6 +142,7 @@ _mdadm()
;; ;;
esac esac
fi fi
[[ $COMPREPLY == *= ]] && compopt -o nospace
else else
cur=${cur:=/dev/} cur=${cur:=/dev/}
_filedir _filedir

View File

@ -28,9 +28,10 @@ _mkinitrd()
COMPREPLY=( $( compgen -W '--version --help -v -f --preload \ COMPREPLY=( $( compgen -W '--version --help -v -f --preload \
--force-scsi-probe --omit-scsi-modules \ --force-scsi-probe --omit-scsi-modules \
--omit-ide-modules --image-version --force-raid-probe \ --omit-ide-modules --image-version --force-raid-probe \
--omit-raid-modules --with --force-lvm-probe \ --omit-raid-modules --with= --force-lvm-probe \
--omit-lvm-modules --builtin --omit-dmraid --net-dev \ --omit-lvm-modules --builtin --omit-dmraid --net-dev \
--fstab --nocompress --dsdt --bootchart' -- "$cur" ) ) --fstab --nocompress --dsdt --bootchart' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else else
local args local args
_count_args _count_args

View File

@ -49,6 +49,8 @@ _mysqladmin()
flush-logs flush-status flush-tables flush-threads flush-privileges \ flush-logs flush-status flush-tables flush-threads flush-privileges \
kill password old-password ping processlist reload refresh shutdown \ kill password old-password ping processlist reload refresh shutdown \
status start-slave stop-slave variables version' -- "$cur" ) ) status start-slave stop-slave variables version' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
} && } &&
complete -F _mysqladmin mysqladmin complete -F _mysqladmin mysqladmin

View File

@ -23,6 +23,7 @@ _mii_tool()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else else
_available_interfaces -a _available_interfaces -a
fi fi

View File

@ -23,6 +23,7 @@ _pkg_config()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else else
COMPREPLY=( $( compgen -W "$( pkg-config --list-all \ COMPREPLY=( $( compgen -W "$( pkg-config --list-all \
2>/dev/null | awk '{print $1}' )" -- "$cur" ) ) 2>/dev/null | awk '{print $1}' )" -- "$cur" ) )

View File

@ -48,6 +48,7 @@ _createdb()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else else
_pg_databases _pg_databases
fi fi
@ -80,6 +81,7 @@ _dropdb()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else else
_pg_databases _pg_databases
fi fi
@ -126,6 +128,7 @@ _psql()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
# return list of available options # return list of available options
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else else
# return list of available databases # return list of available databases
_pg_databases _pg_databases

View File

@ -116,8 +116,8 @@ _rpm()
$split && return 0 $split && return 0
# options common to all modes # options common to all modes
local opts="--define --eval --macros --nodigest --nosignature --rcfile \ local opts="--define= --eval= --macros= --nodigest --nosignature \
--quiet --pipe --verbose" --rcfile= --quiet --pipe --verbose"
case ${words[1]} in case ${words[1]} in
-[iFU]*|--install|--freshen|--upgrade) -[iFU]*|--install|--freshen|--upgrade)
@ -125,10 +125,10 @@ _rpm()
COMPREPLY=( $( compgen -W "$opts --percent --force \ COMPREPLY=( $( compgen -W "$opts --percent --force \
--test --replacepkgs --replacefiles --root \ --test --replacepkgs --replacefiles --root \
--excludedocs --includedocs --noscripts --ignorearch \ --excludedocs --includedocs --noscripts --ignorearch \
--dbpath --prefix --ignoreos --nodeps --allfiles \ --dbpath --prefix= --ignoreos --nodeps --allfiles \
--ftpproxy --ftpport --justdb --httpproxy --httpport \ --ftpproxy --ftpport --justdb --httpproxy --httpport \
--noorder --relocate --badreloc --notriggers \ --noorder --relocate= --badreloc --notriggers \
--excludepath --ignoresize --oldpackage \ --excludepath= --ignoresize --oldpackage \
--queryformat --repackage --nosuggests" -- "$cur" ) ) --queryformat --repackage --nosuggests" -- "$cur" ) )
else else
_filedir '[rs]pm' _filedir '[rs]pm'
@ -148,7 +148,7 @@ _rpm()
opts+=" --changelog --configfiles --conflicts --docfiles opts+=" --changelog --configfiles --conflicts --docfiles
--dump --enhances --filesbypkg --filecaps --fileclass --dump --enhances --filesbypkg --filecaps --fileclass
--filecolor --fileprovide --filerequire --filesbypkg --info --filecolor --fileprovide --filerequire --filesbypkg --info
--list --obsoletes --pipe --provides --queryformat --rcfile --list --obsoletes --pipe --provides --queryformat=
--requires --scripts --suggests --triggers --xml" --requires --scripts --suggests --triggers --xml"
if [[ ${words[@]} == *\ -@(*([^ -])f|-file )* ]]; then if [[ ${words[@]} == *\ -@(*([^ -])f|-file )* ]]; then
@ -175,7 +175,7 @@ _rpm()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W "$opts --all --file --fileid COMPREPLY=( $( compgen -W "$opts --all --file --fileid
--dbpath --fscontext --ftswalk --group --hdrid --last --dbpath --fscontext --ftswalk --group --hdrid --last
--package --pkgid --root --specfile --state --package --pkgid --root= --specfile --state
--triggeredby --whatprovides --whatrequires" \ --triggeredby --whatprovides --whatrequires" \
-- "$cur" ) ) -- "$cur" ) )
elif [[ ${words[@]} != *\ -@(*([^ -])a|-all )* ]]; then elif [[ ${words[@]} != *\ -@(*([^ -])a|-all )* ]]; then
@ -193,7 +193,7 @@ _rpm()
;; ;;
-[Vy]*|--verify) -[Vy]*|--verify)
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W "$opts --root --dbpath --nodeps \ COMPREPLY=( $( compgen -W "$opts --root= --dbpath --nodeps \
--nogroup --nolinkto --nomode --nomtime --nordev --nouser \ --nogroup --nolinkto --nomode --nomtime --nordev --nouser \
--nofiles --noscripts --nomd5 --querytags --specfile \ --nofiles --noscripts --nomd5 --querytags --specfile \
--whatrequires --whatprovides" -- "$cur" ) ) --whatrequires --whatprovides" -- "$cur" ) )
@ -216,13 +216,14 @@ _rpm()
;; ;;
--import|--dbpath|--root) --import|--dbpath|--root)
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--import --dbpath --root' \ COMPREPLY=( $( compgen -W '--import --dbpath --root=' \
-- "$cur" ) ) -- "$cur" ) )
else else
_filedir _filedir
fi fi
;; ;;
esac esac
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
} && } &&
@ -271,6 +272,7 @@ _rpmbuild()
if [[ $cur == -* ]]; then if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W "$( _parse_help "$1" )" -- "$cur" ) ) COMPREPLY=( $( compgen -W "$( _parse_help "$1" )" -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi

View File

@ -167,6 +167,7 @@ _chpasswd()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi
} && } &&
@ -193,6 +194,7 @@ _newusers()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi
@ -234,6 +236,7 @@ _groupadd()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi
} && } &&
@ -258,6 +261,7 @@ _groupmod()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi
@ -382,6 +386,7 @@ _faillog()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi
} && } &&
@ -407,6 +412,7 @@ _lastlog()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi
} && } &&

View File

@ -154,10 +154,12 @@ _smartctl()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--help --version --info --all --xall COMPREPLY=( $( compgen -W '--help --version --info --all --xall
--scan --scan-open --quietmode --device --tolerance --badsum --scan --scan-open --quietmode= --device= --tolerance= --badsum=
--report --nocheck --smart --offlineauto --saveauto --health --report= --nocheck= --smart= --offlineauto= --saveauto= --health
--capabilities --attributes --log --vendorattribute --firmwarebug --capabilities --attributes --log= --vendorattribute=
--presets --drivedb --test --captive --abort' -- "$cur" ) ) --firmwarebug= --presets= --drivedb= --test= --captive --abort' \
-- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else else
cur=${cur:=/dev/} cur=${cur:=/dev/}
_filedir _filedir

View File

@ -116,15 +116,12 @@ _sysbench()
fi fi
done done
# Long options need the "=" (whitespace split doesn't work), so we
# include it in completions that require a value.
local opts="--num-threads= --max-requests= --max-time= --thread-stack-size= local opts="--num-threads= --max-requests= --max-time= --thread-stack-size=
--init-rng= --debug= --validate= --help --version" --init-rng= --debug= --validate= --help --version"
if [[ $test ]]; then if [[ $test ]]; then
local help=( $( _parse_help "$1" "--test=$test help" ) ) local help=( $( _parse_help "$1" "--test=$test help" ) )
opts+=" ${help[@]/%/=} prepare run cleanup help version" opts+=" ${help[@]} prepare run cleanup help version"
else else
opts+=" --test=" opts+=" --test="
fi fi

View File

@ -29,6 +29,7 @@ _wol()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi

View File

@ -21,6 +21,7 @@ _wvdial()
case $cur in case $cur in
-*) -*)
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
;; ;;
*) *)
# start with global and personal config files # start with global and personal config files

View File

@ -9,6 +9,7 @@ _xz()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" --long-help ) {-1..-9}' \ COMPREPLY=( $( compgen -W '$( _parse_help "$1" --long-help ) {-1..-9}' \
-- "$cur" ) ) -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi
@ -62,6 +63,7 @@ _xzdec()
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0 return 0
fi fi

View File

@ -50,15 +50,15 @@ assert_bash_list "-one" $cmd "internal dash 2"
sync_after_int sync_after_int
set cmd {fn() { printf '%s\n' "--long-arg=value"; }; _parse_help fn} set cmd {fn() { printf '%s\n' "--long-arg=value"; }; _parse_help fn}
assert_bash_list "--long-arg" $cmd "value stripped" assert_bash_list "--long-arg=" $cmd "value stripped"
sync_after_int sync_after_int
set cmd {fn() { printf '%s\n' "--long-arg=-value"; }; _parse_help fn} set cmd {fn() { printf '%s\n' "--long-arg=-value"; }; _parse_help fn}
assert_bash_list "--long-arg" $cmd "value not seen as option" assert_bash_list "--long-arg=" $cmd "value not seen as option"
sync_after_int sync_after_int
set cmd {fn() { printf '%s\n' "--long-arg=-value,--opt2=val"; }; _parse_help fn} set cmd {fn() { printf '%s\n' "--long-arg=-value,--opt2=val"; }; _parse_help fn}
assert_bash_list "--long-arg" $cmd "two options with values" assert_bash_list "--long-arg=" $cmd "two options with values"
sync_after_int sync_after_int
set cmd {fn() { printf '%s\n' "-m,--mirror"; }; _parse_help fn} set cmd {fn() { printf '%s\n' "-m,--mirror"; }; _parse_help fn}
@ -82,11 +82,11 @@ assert_bash_list "--foo" $cmd "long with value and eq sign in brackets"
sync_after_int sync_after_int
set cmd {fn() { printf '%s\n' "--foo=<bar>"; }; _parse_help fn} set cmd {fn() { printf '%s\n' "--foo=<bar>"; }; _parse_help fn}
assert_bash_list "--foo" $cmd "long with value in angle brackets" assert_bash_list "--foo=" $cmd "long with value in angle brackets"
sync_after_int sync_after_int
set cmd {fn() { printf '%s\n' "--foo={bar,quux}"; }; _parse_help fn} set cmd {fn() { printf '%s\n' "--foo={bar,quux}"; }; _parse_help fn}
assert_bash_list "--foo" $cmd "long with value in curly brackets" assert_bash_list "--foo=" $cmd "long with value in curly brackets"
sync_after_int sync_after_int
set cmd {fn() { printf '%s\n' "--[no]foo"; }; _parse_help fn} set cmd {fn() { printf '%s\n' "--[no]foo"; }; _parse_help fn}