[Pkg-zsh-devel] Bug#962133: Bug#962133: zsh-common: missing package in "dpkg -s" completion

Vincent Lefevre vincent at vinc17.net
Wed Jun 3 17:38:03 BST 2020


The issue is that
/usr/share/zsh/functions/Completion/Debian/_deb_packages
just considers packages in states install and hold:

_deb_packages_update_installed () {
  if ( [[ ${+_deb_packages_cache_installed} -eq 0 ]] ||
      _cache_invalid DEBS_installed ) && ! _retrieve_cache DEBS_installed;
  then
    _deb_packages_cache_installed=()
    dpkg --get-selections | while read package state ; do
        [[ $state = (install|hold) ]] && _deb_packages_cache_installed+=$package
    done
    _store_cache DEBS_installed _deb_packages_cache_installed
  fi
  cachevar=_deb_packages_cache_installed
}

Instead, any state should be valid for "dpkg -s" completion.
It seems that this is what _deb_packages_update_xinstalled does:

xinstalled () {
  if ( [[ ${+_deb_packages_cache_xinstalled} -eq 0 ]] ||
      _cache_invalid DEBS_xinstalled ) && ! _retrieve_cache DEBS_xinstalled;
  then
    _deb_packages_cache_xinstalled=()
    dpkg --get-selections | while read package state ; do
        _deb_packages_cache_xinstalled+=$package
    done
    _store_cache DEBS_xinstalled _deb_packages_cache_xinstalled
  fi
  cachevar=_deb_packages_cache_xinstalled
}

So the fix should be easy: in
/usr/share/zsh/functions/Completion/Debian/_dpkg

  remove|status|listfiles)
    _call_function ret _dpkg_$state && return ret
    _arguments -C -A "-*" -s "$_dpkg_options[@]" \
       '*:package:_deb_packages installed'
  ;;
  purge)
    _call_function ret _dpkg_$state && return ret
    _arguments -C -A "-*" -s "$_dpkg_options[@]" \
       '*:package:_deb_packages xinstalled'
  ;;

move "status" and "listfiles" to "purge" (which uses xinstalled).

Still, "remove" and "purge" would remain inconsistent, which
is another bug...

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



More information about the Pkg-zsh-devel mailing list