From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29452 invoked by alias); 31 Oct 2016 12:49:24 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39791 Received: (qmail 19433 invoked from network); 31 Oct 2016 12:49:24 -0000 X-Qmail-Scanner-Diagnostics: from relay2.uni-heidelberg.de by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(129.206.119.212):SA:0(-1.5/5.0):. Processed in 1.282466 secs); 31 Oct 2016 12:49:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=RP_MATCHES_RCVD autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: pseyfert@mathphys.fsk.uni-heidelberg.de X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at mathphys.fsk.uni-heidelberg.de does not designate permitted sender hosts) Subject: Re: PATCH Completion for _yum (contains FIXMEs) To: zsh-workers@zsh.org References: <61b3fb7c-4de6-d8da-29b4-b3802d98b162@mathphys.fsk.uni-heidelberg.de> <20161027013054.GA15799@fujitsu.shahaf.local2> From: Paul Seyfert X-Enigmail-Draft-Status: N1110 Message-ID: <484fa75d-9361-df92-06b4-54fad37231f4@mathphys.fsk.uni-heidelberg.de> Date: Mon, 31 Oct 2016 13:09:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161027013054.GA15799@fujitsu.shahaf.local2> Content-Type: multipart/mixed; boundary="------------73556C069130926AA3C25AE7" --------------73556C069130926AA3C25AE7 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi, thanks for the suggestions. On 27.10.2016 03:30, Daniel Shahaf wrote: > Something like this: > . > _id_ranges() { if compset -P '*..'; then _ids; else _ids -S ..; fi } > . > where _ids() is a function that adds "1" "2" "3" as completions. > > There should be examples of this in the revision ranges handling in > _git/_hg/_subversion. > added the id ranges similar to your suggestion and checking _git. >> [snap] > > This looks like it would be better written with _alternative: > > alts=() > [[ -n "${ID_range_commands[(r)$words[2]]}" ]] && alts+=( 'id-ranges:id ranges:_id-ranges' ) > [[ -n "${package_commands[(r)$words[2]]}" ]] && alts+=( 'packages:packages:...' ) > ⋮ > (( ${+alts[1]} )) && _alternative "$alts[@]" > > To see the difference, set the «group-name» style to «''» (and > optionally the «format» style to something with «%d» in it). You can > see this in «ssh » too (compare with/without those two styles). also i'm using _alternative by now, but i'll bring it closer to your suggestion soonish. Cheers, Paul --------------73556C069130926AA3C25AE7 Content-Type: text/x-patch; name="just_changes2.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="just_changes2.patch" diff --git a/Completion/Redhat/Command/_yum b/Completion/Redhat/Command/_= yum index f453806..f9219f0 100644 --- a/Completion/Redhat/Command/_yum +++ b/Completion/Redhat/Command/_yum @@ -53,6 +53,18 @@ _yum() "shell:enter the 'yum shell'" "update:update one or more packages" "upgrade:upgrade one or more packages" + "update-to:update one or more packages taking obsoletes into account" + "upgrade-to:upgrade one or more packages taking obsoletes into account= " + "history:view past transactions" + "help:produce help for all or given command" + "load-transaction:load a saved transaction from a textfile" + "load-ts:load a saved transaction from a textfile" + "check:Check for problems in the rpmdb" + "reinstall:reinstall a package" + "downgrade:downgrade a package" + "repolist:Display the configured software repositories" + "distribution-synchronization:Synchronize installed packages to the la= test available versions" + "distro-sync:Synchronize installed packages to the latest available ve= rsions" ) =20 if (( CURRENT =3D=3D 1 )); then @@ -66,6 +78,10 @@ _yum() remove) cmd=3D"erase";; whatprovides) cmd=3D"provides";; upgrade) cmd=3D"update";; + upgrade-to) cmd=3D"update";; + update-to) cmd=3D"update";; + load-ts) cmd=3D"load-transaction";; + distro-sync) cmd=3D"distribution-synchronization";; esac =09 if (( $#cmd )); then @@ -77,7 +93,17 @@ _yum() zstyle ":completion:${curcontext}:" cache-policy _yum_caching_policy= fi =20 + if [ "$cmd" =3D "help" ]; then + if (( CURRENT =3D=3D 2 )); then + local -a _yum_cmd_names + _yum_cmd_names=3D(${_yum_cmds%%:*}) + _describe -t commands 'commands' _yum_cmd_names + else + _message 'no more arguments' + fi + else _call_function ret _yum_$cmd || _message 'no more arguments' + fi else _message "unknown yum command: $words[1]" fi @@ -85,6 +111,101 @@ _yum() fi } =20 +# Expand next argument after 'yum check' +_yum_check() { + if (( CURRENT =3D=3D 2 )); then + local -a chkargs + #chkargs=3D("dependencies" "duplicates" "obsoletes" "provides" "all"= ) # according to man page + #chkargs=3D("dependencies" "duplicates" "all") # according to help + chkargs=3D("dependencies" "duplicates" "provides" "all") # what work= s for me + _describe -t arguments 'check arguments' chkargs + fi + return 0 +} + +# Expand next argument after 'yum repolist' +_yum_repolist() { + if (( CURRENT =3D=3D 2 )); then + local -a suggests + suggests=3D("all" "enabled" "disabled") + _describe -t arguments 'repolist arguments' suggests + fi + return 0 +} + +_ids() { + # the last argument will be the first valid transaction ID to be sugge= sted + # all other arguments are forwarded to compadd + # + # maxid is the last transaction ID known to yum + # minusone is the number of arguments provided to _ids minus one + local maxid + local minusone + + maxid=3D$(yum history stats | grep Transactions | sed "s/.*: //") + ((minusone=3D$#-1)) + compadd "${(@)@[1,$minusone]}" $(echo {$@[$#]..$maxid}) +} + +_ranges() { + if compset -P '*..'; then + _ids ${(S)IPREFIX#..} + else + _ids -S '..' 1 + fi +} + +# Expand next argument after 'yum history' +_yum_history() { + if (( CURRENT =3D=3D 2 )); then + local -a historycommands + historycommands=3D('info' 'list' 'packages-list' 'packages-info' 'su= mmary' 'addon-info' 'redo' 'undo' 'roll-back' 'new' 'sync' 'stats') + _describe -t commands 'yum history command' historycommands + fi + if (( CURRENT =3D=3D 3 )); then + local -a ID_commands + local -a ID_range_commands + local -a package_commands + local -a suggests + suggests=3D() + #ID_commands=3D('summary' 'info' 'list' 'stats' 'addon-info') + ID_commands=3D('addon-info') + ID_range_commands=3D('summary' 'info' 'list' 'stats') + package_commands=3D('summary' 'info' 'list' 'stats' 'packages-list' = 'packages-info') + #package_commands=3D('packages-list' 'packages-info') + # packages-list, packages-info : needs package name + # summary, info, list, stats : ID, ID range, package name + # addon-info : ID + # redo, undo, roll-back, sync : unknown + if [[ -n "${ID_commands[(r)$words[2]]}" ]]; then + suggests+=3D(':special IDs:(last)') + suggests+=3D(':IDs:_ids 1') + fi + if [[ -n "${ID_range_commands[(r)$words[2]]}" ]]; then + suggests+=3D(':transaction ranges:_ranges') + suggests+=3D(':all transactions:(all)') + fi + if [[ -n "${package_commands[(r)$words[2]]}" ]]; then + _yum_installed_pkgs + #suggests+=3D(":packages:($_installed_pkgs)") + suggests+=3D(":packages:_yum_act_on_installed_pkgs") + fi + if [[ 0 -eq ${#suggests} ]] ; then + _message "unknown expansion for: yum history $words[2]" + else + _alternative $suggests + fi + fi + if (( CURRENT =3D=3D 4 )); then + if [ "$words[2]" =3D "addon-info" ]; then + local -a historyargs + historyargs=3D(saved_tx) + _describe 'additional option' historyargs + fi + fi +} + + # Fills the all pkg cache _yum_all_pkgs() { @@ -163,11 +284,34 @@ yum_repos() { compadd "$@" -a -- enabled_yum_repos } =20 +# Suggest installed packages +_yum_act_on_installed_pkgs() { + _yum_installed_pkgs + compadd "$@" -a -- _installed_pkgs +} + +# Completion function for distribution-synchronization|distro-sync +(( $+functions[_yum_distribution-synchronization] )) || _yum_distributio= n-synchronization() +{ + _yum_act_on_installed_pkgs +} + # Completion function for erase|remove (( $+functions[_yum_erase] )) || _yum_erase() { - _yum_installed_pkgs - compadd "$@" -a -- _installed_pkgs + _yum_act_on_installed_pkgs +} + +# Completion function for downgrade +(( $+functions[_yum_downgrade] )) || _yum_downgrade() +{ + _yum_act_on_installed_pkgs +} + +# Completion function for reinstall +(( $+functions[_yum_reinstall] )) || _yum_reinstall() +{ + _yum_act_on_installed_pkgs } =20 # Completion function for install @@ -191,6 +335,12 @@ yum_repos() { return ret } =20 +# Completion function for load-transaction +(( $+functions[_yum_load-transaction] )) || _yum_load-transaction() +{ + _files +} + # Completion function for localinstall (( $+functions[_yum_localinstall] )) || _yum_localinstall() { --------------73556C069130926AA3C25AE7 Content-Type: text/x-patch; name="extend-yum-completion2.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="extend-yum-completion2.patch" diff --git a/Completion/Redhat/Command/_yum b/Completion/Redhat/Command/_= yum index f453806..4cc00cf 100644 --- a/Completion/Redhat/Command/_yum +++ b/Completion/Redhat/Command/_yum @@ -3,293 +3,443 @@ # Main dispatcher _yum()=20 { - local curcontext=3D"$curcontext" state lstate line - - _arguments -s \ - '(- *)'{-h,--help}'[show the help message]' \ - '(-t --tolerant)'{-t,--tolerant}'[be tolerant of errors]' \ - '(-C --cacheonly)'{-C,--cacheonly}'[run entirely from cache]' \ - '(-c --config)'{-c,--config=3D}'[config file location]:Yum conf file= :_files' \ - '(-R --randomwait)'{-R,--randomwait=3D}'[maximum command wait time (= in minutes)]:max wait time' \ - '(-d --debuglevel)'{-d,--debuglevel=3D}'[debug level (0-10)]:debug l= evel' \ - '(-e --errorlevel)'{-e,--errorlevel=3D}'[error level (0-10)]:error l= evel' \ - '(-y --assumeyes)'{-y,--assumeyes}'[answer yes for all questions]' \= - '--installroot=3D[set install root]:install root:_files -/' \ - '*--enablerepo=3D[enable or or more repositories]:repos to enable:_y= um_disabled_repos_list' \ - '*--disablerepo=3D[disable one or more repositories]:disable repos:_= yum_enabled_repos_list' \ - {*-x,*--exclude=3D}'[exclude package(s) by name or glob]:exclude pac= kages' \ - '--version[show yum version]' \ - '--obsoletes[enable obsoletes processing during updates]' \ - '--nogpgcheck[disable gpg signature checking]' \ - '--noplugins[disable yum plugins]' \ - '--disablepresto[disable Presto plugin and don''''t download any del= tarpms]' \ - '*::yum command:_yum_command' + local curcontext=3D"$curcontext" state lstate line + + _arguments -s \ + '(- *)'{-h,--help}'[show the help message]' \ + '(-t --tolerant)'{-t,--tolerant}'[be tolerant of errors]' \ + '(-C --cacheonly)'{-C,--cacheonly}'[run entirely from cache]' \ + '(-c --config)'{-c,--config=3D}'[config file location]:Yum conf file= :_files' \ + '(-R --randomwait)'{-R,--randomwait=3D}'[maximum command wait time (= in minutes)]:max wait time' \ + '(-d --debuglevel)'{-d,--debuglevel=3D}'[debug level (0-10)]:debug l= evel' \ + '(-e --errorlevel)'{-e,--errorlevel=3D}'[error level (0-10)]:error l= evel' \ + '(-y --assumeyes)'{-y,--assumeyes}'[answer yes for all questions]' \= + '--installroot=3D[set install root]:install root:_files -/' \ + '*--enablerepo=3D[enable or or more repositories]:repos to enable:_y= um_disabled_repos_list' \ + '*--disablerepo=3D[disable one or more repositories]:disable repos:_= yum_enabled_repos_list' \ + {*-x,*--exclude=3D}'[exclude package(s) by name or glob]:exclude pac= kages' \ + '--version[show yum version]' \ + '--obsoletes[enable obsoletes processing during updates]' \ + '--nogpgcheck[disable gpg signature checking]' \ + '--noplugins[disable yum plugins]' \ + '--disablepresto[disable Presto plugin and don''''t download any d= eltarpms]' \ + '*::yum command:_yum_command' } =20 (( $+functions[_yum_command] )) || _yum_command()=20 { - local -a _yum_cmds - _yum_cmds=3D( - "install:install the latest version of a package or group of packages"= - "erase:remove an installed package (with its dependencies)" - "remove:remove an installed package (with its dependencies)" - "clean:clean local yum cache" - "deplist:gives a list of all dependencies for a package" - "check-update:check if any updates are available" - "info:get description of available packages" - "list:is used to list various information about packages" - "groupinfo:get info on package groups" - "groupinstall:install a package group or groups" - "groupremove:remove a package group or groups" - "grouplist:list package groups" - "groupupdate:update a package group or groups" - "localinstall:install packages with local rpm files" - "localupdate:update packages with local rpm files" - "makecache:makes a local yum cache" - "provides:find out which package provides some feature or file" - "whatprovides:find out which package provides some feature or file" - "resolvedep:list packages providing the specified dependencies" - "search:find any packages matching pattern" - "shell:enter the 'yum shell'" - "update:update one or more packages" - "upgrade:upgrade one or more packages" - ) - - if (( CURRENT =3D=3D 1 )); then - _describe -t commands 'yum command' _yum_cmds || compadd "$@" - else - local curcontext=3D"$curcontext" - - cmd=3D"${${_yum_cmds[(r)$words[1]:*]%%:*}}" - # Deal with any aliases - case $cmd in - remove) cmd=3D"erase";; - whatprovides) cmd=3D"provides";; - upgrade) cmd=3D"update";; - esac - =09 - if (( $#cmd )); then - curcontext=3D"${curcontext%:*:*}:yum-${cmd}:" -=09 - local update_policy - zstyle -s ":completion:${curcontext}:" cache-policy update_policy - if [[ -z "$update_policy" ]]; then - zstyle ":completion:${curcontext}:" cache-policy _yum_caching_policy= - fi - - _call_function ret _yum_$cmd || _message 'no more arguments' - else - _message "unknown yum command: $words[1]" - fi - return ret - fi + local -a _yum_cmds + _yum_cmds=3D( + "install:install the latest version of a package or group of packages"= + "erase:remove an installed package (with its dependencies)" + "remove:remove an installed package (with its dependencies)" + "clean:clean local yum cache" + "deplist:gives a list of all dependencies for a package" + "check-update:check if any updates are available" + "info:get description of available packages" + "list:is used to list various information about packages" + "groupinfo:get info on package groups" + "groupinstall:install a package group or groups" + "groupremove:remove a package group or groups" + "grouplist:list package groups" + "groupupdate:update a package group or groups" + "localinstall:install packages with local rpm files" + "localupdate:update packages with local rpm files" + "makecache:makes a local yum cache" + "provides:find out which package provides some feature or file" + "whatprovides:find out which package provides some feature or file" + "resolvedep:list packages providing the specified dependencies" + "search:find any packages matching pattern" + "shell:enter the 'yum shell'" + "update:update one or more packages" + "upgrade:upgrade one or more packages" + "update-to:update one or more packages taking obsoletes into account" + "upgrade-to:upgrade one or more packages taking obsoletes into account= " + "history:view past transactions" + "help:produce help for all or given command" + "load-transaction:load a saved transaction from a textfile" + "load-ts:load a saved transaction from a textfile" + "check:Check for problems in the rpmdb" + "reinstall:reinstall a package" + "downgrade:downgrade a package" + "repolist:Display the configured software repositories" + "distribution-synchronization:Synchronize installed packages to the la= test available versions" + "distro-sync:Synchronize installed packages to the latest available ve= rsions" + ) + + if (( CURRENT =3D=3D 1 )); then + _describe -t commands 'yum command' _yum_cmds || compadd "$@" + else + local curcontext=3D"$curcontext" + + cmd=3D"${${_yum_cmds[(r)$words[1]:*]%%:*}}" + # Deal with any aliases + case $cmd in + remove) cmd=3D"erase";; + whatprovides) cmd=3D"provides";; + upgrade) cmd=3D"update";; + upgrade-to) cmd=3D"update";; + update-to) cmd=3D"update";; + load-ts) cmd=3D"load-transaction";; + distro-sync) cmd=3D"distribution-synchronization";; + esac + + if (( $#cmd )); then + curcontext=3D"${curcontext%:*:*}:yum-${cmd}:" + + local update_policy + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _yum_caching_po= licy + fi + + if [ "$cmd" =3D "help" ]; then + if (( CURRENT =3D=3D 2 )); then + local -a _yum_cmd_names + _yum_cmd_names=3D(${_yum_cmds%%:*}) + _describe -t commands 'commands' _yum_cmd_names + else + _message 'no more arguments' + fi + else + _call_function ret _yum_$cmd || _message 'no more arguments' + fi + else + _message "unknown yum command: $words[1]" + fi + return ret + fi +} + +# Expand next argument after 'yum check' +_yum_check() { + if (( CURRENT =3D=3D 2 )); then + local -a chkargs + #chkargs=3D("dependencies" "duplicates" "obsoletes" "provides" "all"= ) # according to man page + #chkargs=3D("dependencies" "duplicates" "all") # according to help + chkargs=3D("dependencies" "duplicates" "provides" "all") # what work= s for me + _describe -t arguments 'check arguments' chkargs + fi + return 0 +} + +# Expand next argument after 'yum repolist' +_yum_repolist() { + if (( CURRENT =3D=3D 2 )); then + local -a suggests + suggests=3D("all" "enabled" "disabled") + _describe -t arguments 'repolist arguments' suggests + fi + return 0 +} + +_ids() { + # the last argument will be the first valid transaction ID to be sugge= sted + # all other arguments are forwarded to compadd + # + # maxid is the last transaction ID known to yum + # minusone is the number of arguments provided to _ids minus one + local maxid + local minusone + + maxid=3D$(yum history stats | grep Transactions | sed "s/.*: //") + ((minusone=3D$#-1)) + compadd "${(@)@[1,$minusone]}" $(echo {$@[$#]..$maxid}) } =20 +_ranges() { + if compset -P '*..'; then + _ids ${(S)IPREFIX#..} + else + _ids -S '..' 1 + fi +} + +# Expand next argument after 'yum history' +_yum_history() { + if (( CURRENT =3D=3D 2 )); then + local -a historycommands + historycommands=3D('info' 'list' 'packages-list' 'packages-info' 'su= mmary' 'addon-info' 'redo' 'undo' 'roll-back' 'new' 'sync' 'stats') + _describe -t commands 'yum history command' historycommands + fi + if (( CURRENT =3D=3D 3 )); then + local -a ID_commands + local -a ID_range_commands + local -a package_commands + local -a suggests + suggests=3D() + #ID_commands=3D('summary' 'info' 'list' 'stats' 'addon-info') + ID_commands=3D('addon-info') + ID_range_commands=3D('summary' 'info' 'list' 'stats') + package_commands=3D('summary' 'info' 'list' 'stats' 'packages-list' = 'packages-info') + #package_commands=3D('packages-list' 'packages-info') + # packages-list, packages-info : needs package name + # summary, info, list, stats : ID, ID range, package name + # addon-info : ID + # redo, undo, roll-back, sync : unknown + if [[ -n "${ID_commands[(r)$words[2]]}" ]]; then + suggests+=3D(':special IDs:(last)') + suggests+=3D(':IDs:_ids 1') + fi + if [[ -n "${ID_range_commands[(r)$words[2]]}" ]]; then + suggests+=3D(':transaction ranges:_ranges') + suggests+=3D(':all transactions:(all)') + fi + if [[ -n "${package_commands[(r)$words[2]]}" ]]; then + _yum_installed_pkgs + #suggests+=3D(":packages:($_installed_pkgs)") + suggests+=3D(":packages:_yum_act_on_installed_pkgs") + fi + if [[ 0 -eq ${#suggests} ]] ; then + _message "unknown expansion for: yum history $words[2]" + else + _alternative $suggests + fi + fi + if (( CURRENT =3D=3D 4 )); then + if [ "$words[2]" =3D "addon-info" ]; then + local -a historyargs + historyargs=3D(saved_tx) + _describe 'additional option' historyargs + fi + fi +} + + # Fills the all pkg cache _yum_all_pkgs() { - if ( [[ ${+_all_pkgs} -eq 0 ]] || _cache_invalid ALL ) && - ! _retrieve_cache ALL; - then - _all_pkgs=3D( $(yum -C list all | sed 's/\s.*//' | grep '\.' 2>/dev/nu= ll) ) - _store_cache ALL _all_pkgs - fi + if ( [[ ${+_all_pkgs} -eq 0 ]] || _cache_invalid ALL ) && + ! _retrieve_cache ALL; +then + _all_pkgs=3D( $(yum -C list all | sed 's/\s.*//' | grep '\.' 2>/dev/nu= ll) ) + _store_cache ALL _all_pkgs +fi } =20 # Fills the installed pkg cache _yum_installed_pkgs() { - if ( [[ ${+_installed_pkgs} -eq 0 ]] || _cache_invalid INSTALLED ) && - ! _retrieve_cache INSTALLED; - then - _installed_pkgs=3D( $(yum -C list installed | sed 's/\s.*//' | grep '\= =2E' 2>/dev/null) ) - _store_cache INSTALLED _installed_pkgs - fi + if ( [[ ${+_installed_pkgs} -eq 0 ]] || _cache_invalid INSTALLED ) && + ! _retrieve_cache INSTALLED; +then + _installed_pkgs=3D( $(yum -C list installed | sed 's/\s.*//' | grep '\= =2E' 2>/dev/null) ) + _store_cache INSTALLED _installed_pkgs +fi } =20 # Fills the available pkg cache _yum_available_pkgs() { - if ( [[ ${+_available_pkgs} -eq 0 ]] || _cache_invalid AVAILABLE ) && - ! _retrieve_cache AVAILABLE; - then - _available_pkgs=3D( $(yum -C list available | sed 's/\s.*//' | grep '\= =2E' 2>/dev/null) ) - _store_cache AVAILABLE _available_pkgs - fi + if ( [[ ${+_available_pkgs} -eq 0 ]] || _cache_invalid AVAILABLE ) && + ! _retrieve_cache AVAILABLE; +then + _available_pkgs=3D( $(yum -C list available | sed 's/\s.*//' | grep '\= =2E' 2>/dev/null) ) + _store_cache AVAILABLE _available_pkgs +fi } =20 # Fills the upgrade pkg cache _yum_upgrade_pkgs() { - if ( [[ ${+_upgrade_pkgs} -eq 0 ]] || _cache_invalid UPGRADE ) && - ! _retrieve_cache UPGRADE; - then - _upgrade_pkgs=3D( $(yum -C list upgrade | sed 's/\s.*//' | grep '\.' 2= >/dev/null) ) - _store_cache UPGRADE _upgrade_pkgs - fi + if ( [[ ${+_upgrade_pkgs} -eq 0 ]] || _cache_invalid UPGRADE ) && + ! _retrieve_cache UPGRADE; +then + _upgrade_pkgs=3D( $(yum -C list upgrade | sed 's/\s.*//' | grep '\.' 2= >/dev/null) ) + _store_cache UPGRADE _upgrade_pkgs +fi } =20 # Gets the list of defined repos yum_repos() { - local trepo - local -a tarray - tarray=3D( $(egrep -h '(^\[.*\]|^enabled.*=3D)' /etc/yum.repos.d/*.r= epo /etc/yum.conf | sed -e 's/ //g' | sed -e 's/\[//g' | sed -e 's/\].*$/= /g' 2>/dev/null) ) - local -i eindex=3D0 - local -i dindex=3D0 - for line in $tarray; do - if [[ "$line" =3D "enabled=3D1" ]]; then - enabled_yum_repos=3D($enabled_yum_repos $trepo) - elif [[ "$line" =3D "enabled=3D0" ]]; then - disabled_yum_repos=3D($disabled_yum_repos $trepo) - elif [[ "$line" !=3D "main" ]]; then - trepo=3D$line - fi - done + local trepo + local -a tarray + tarray=3D( $(egrep -h '(^\[.*\]|^enabled.*=3D)' /etc/yum.repos.d/*.rep= o /etc/yum.conf | sed -e 's/ //g' | sed -e 's/\[//g' | sed -e 's/\].*$//g= ' 2>/dev/null) ) + local -i eindex=3D0 + local -i dindex=3D0 + for line in $tarray; do + if [[ "$line" =3D "enabled=3D1" ]]; then + enabled_yum_repos=3D($enabled_yum_repos $trepo) + elif [[ "$line" =3D "enabled=3D0" ]]; then + disabled_yum_repos=3D($disabled_yum_repos $trepo) + elif [[ "$line" !=3D "main" ]]; then + trepo=3D$line + fi + done } =20 (( $+functions[_yum_disabled_repos_list] )) || _yum_disabled_repos_list(= ) { - compset -P '*,' - compset -S ',*' - yum_repos =09 - compadd "$@" -a -- disabled_yum_repos + compset -P '*,' + compset -S ',*' + yum_repos =09 + compadd "$@" -a -- disabled_yum_repos } =20 (( $+functions[_yum_enabled_repos_list] )) || _yum_enabled_repos_list() { - compset -P '*,' - compset -S ',*' - yum_repos =09 - compadd "$@" -a -- enabled_yum_repos + compset -P '*,' + compset -S ',*' + yum_repos =09 + compadd "$@" -a -- enabled_yum_repos +} + +# Suggest installed packages +_yum_act_on_installed_pkgs() { + _yum_installed_pkgs + compadd "$@" -a -- _installed_pkgs +} + +# Completion function for distribution-synchronization|distro-sync +(( $+functions[_yum_distribution-synchronization] )) || _yum_distributio= n-synchronization() +{ + _yum_act_on_installed_pkgs } =20 # Completion function for erase|remove (( $+functions[_yum_erase] )) || _yum_erase() { - _yum_installed_pkgs - compadd "$@" -a -- _installed_pkgs + _yum_act_on_installed_pkgs +} + +# Completion function for downgrade +(( $+functions[_yum_downgrade] )) || _yum_downgrade() +{ + _yum_act_on_installed_pkgs +} + +# Completion function for reinstall +(( $+functions[_yum_reinstall] )) || _yum_reinstall() +{ + _yum_act_on_installed_pkgs } =20 # Completion function for install (( $+functions[_yum_install] )) || _yum_install() { - if ! [[ $PREFIX =3D=3D */* ]]; then - _yum_available_pkgs - fi + if ! [[ $PREFIX =3D=3D */* ]]; then + _yum_available_pkgs + fi =20 - local ret=3D1 - _tags files packages - while _tags; do - if _requested files; then - compadd "$@" -a -- _available_pkgs - fi - if _requested packages; then - _call_function - _yum_localinstall - fi - (( ret )) || break - done - return ret + local ret=3D1 + _tags files packages + while _tags; do + if _requested files; then + compadd "$@" -a -- _available_pkgs + fi + if _requested packages; then + _call_function - _yum_localinstall + fi + (( ret )) || break + done + return ret +} + +# Completion function for load-transaction +(( $+functions[_yum_load-transaction] )) || _yum_load-transaction() +{ + _files } =20 # Completion function for localinstall (( $+functions[_yum_localinstall] )) || _yum_localinstall() { - _files -/ -g '(#i)*.rpm(-.)' + _files -/ -g '(#i)*.rpm(-.)' } =20 # Completion function for localupdate (( $+functions[_yum_localupdate] )) || _yum_localupdate() { - _files -/ -g '(#i)*.rpm(-.)' + _files -/ -g '(#i)*.rpm(-.)' } =20 # Completion function for update/upgrade (( $+functions[_yum_update] )) || _yum_update() { - _yum_upgrade_pkgs - compadd "$@" -a -- _upgrade_pkgs + _yum_upgrade_pkgs + compadd "$@" -a -- _upgrade_pkgs } =20 # Completion function for deplist (( $+functions[_yum_deplist] )) || _yum_deplist() { - _yum_available_pkgs - compadd "$@" -a -- _available_pkgs + _yum_available_pkgs + compadd "$@" -a -- _available_pkgs } =20 _yum_all() { - _yum_all_pkgs - compadd "$@" -a -- _all_pkgs + _yum_all_pkgs + compadd "$@" -a -- _all_pkgs } _yum_list_or_info() { - local -a listlist - listlist=3D( - "all:all packages in repositories" - "available:packages available in repositories" - "updates:packages with updates available" - "installed:installed packages" - "extras:packages installed that are not available in any yum repositor= y" - "obsoletes:packages installed that are obsoleted" - "recent:packages recently added to repositories" - ) -=09 - if (( CURRENT =3D=3D 2 )); then - _describe -t yum-list-subcmds "Yum info/list sub-commands" listlist ||= _yum_all - else - local subcmd - subcmd=3D"${${listlist[(r)$words[2]:*]%%:*}}" - # offer packages selected by the subcommand - case $subcmd in - all) _yum_all;; - installed) _yum_erase;; - available) _yum_install;; - updates) _yum_update;; - esac - fi + local -a listlist + listlist=3D( + "all:all packages in repositories" + "available:packages available in repositories" + "updates:packages with updates available" + "installed:installed packages" + "extras:packages installed that are not available in any yum repositor= y" + "obsoletes:packages installed that are obsoleted" + "recent:packages recently added to repositories" + ) + + if (( CURRENT =3D=3D 2 )); then + _describe -t yum-list-subcmds "Yum info/list sub-commands" listlist = || _yum_all + else + local subcmd + subcmd=3D"${${listlist[(r)$words[2]:*]%%:*}}" + # offer packages selected by the subcommand + case $subcmd in + all) _yum_all;; + installed) _yum_erase;; + available) _yum_install;; + updates) _yum_update;; + esac + fi } =20 # Completion function for list (( $+functions[_yum_list] )) || _yum_list() { - _yum_list_or_info + _yum_list_or_info } =20 # Completion function for info (( $+functions[_yum_info] )) || _yum_info() { - _yum_list_or_info + _yum_list_or_info } =20 # Completion function for provides|whatprovides (( $+functions[_yum_provides] )) || _yum_provides() { - _files=09 + _files=09 } =20 # Completion function for resolvedep (( $+functions[_yum_resolvedep] )) || _yum_resolvedep() { - _files=09 + _files=09 } =20 # Completion function for clean (( $+functions[_yum_clean] )) || _yum_clean() { - local -a cleanlist - cleanlist=3D( - "all:all cache" - "cache:all cache" - "dbcache:DB cache" - "headers:cache headers" - "packages:cache packages" - "metadata:cache meta-data" - ) -=09 - if (( CURRENT =3D=3D 2 )); then - _describe -t yum-clean-subcmds "Yum clean sub-commands" cleanlist=20 - fi + local -a cleanlist + cleanlist=3D( + "all:all cache" + "cache:all cache" + "dbcache:DB cache" + "headers:cache headers" + "packages:cache packages" + "metadata:cache meta-data" + ) + + if (( CURRENT =3D=3D 2 )); then + _describe -t yum-clean-subcmds "Yum clean sub-commands" cleanlist=20 + fi } =20 _yum_caching_policy()=20 --------------73556C069130926AA3C25AE7--