From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 6ad71c4f for ; Tue, 30 Jul 2019 14:54:39 +0000 (UTC) Received: (qmail 14456 invoked by alias); 30 Jul 2019 14:54:34 -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: List-Unsubscribe: X-Seq: 44591 Received: (qmail 1513 invoked by uid 1010); 30 Jul 2019 14:54:34 -0000 X-Qmail-Scanner-Diagnostics: from sym2.noone.org by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25524. spamassassin: 3.4.2. Clear:RC:0(178.63.92.236):SA:0(-1.6/5.0):. Processed in 1.184831 secs); 30 Jul 2019 14:54:34 -0000 X-Envelope-From: abe@sym2.noone.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at sym2.noone.org does not designate permitted sender hosts) Date: Tue, 30 Jul 2019 16:53:54 +0200 From: Axel Beckert To: zsh-workers@zsh.org, pkg-zsh-devel@alioth-lists.debian.net Subject: Re: apt autocompletion issue Message-ID: <20190730145353.k2eonyy6w2z7luau@sym.noone.org> Mail-Followup-To: zsh-workers@zsh.org, pkg-zsh-devel@alioth-lists.debian.net MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <325f29f5-fc1c-46fb-94eb-5c6589536652@www.fastmail.com> <79188-1564444425.709181@h-V7.a7lO.lIR7> X-Operating-System: Linux 4.9.0-9-amd64 X-Machine: sym2 x86_64 X-Editor: GNU Emacs 25.1.1 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAAAAAC3mUtaAAAABGdBTUEAALGPC/xhBQAAADh0RVh0U29mdHdhcmUAWFYgVmVyc2lvbiAzLjEwYSAgUmV2OiAxMi8yOS85NCAoUE5HIHBhdGNoIDEuMindFS5JAAACGElEQVQ4jXXQMU8UYRDG8f8shNjdDH4AbpfGDjAWlKiJiZ0ajL1aGCvsNCbGaCGG1koLaztaTYz6ATy+gOyehYmF3MxVxgg3FnDsHcTpJr/M+8w7Rf6nCsaVTTDqxbg9hoOXmw83H71+Eyfg4E1d7/Z2fG9rGkZbTQiu+K+3U/C+76lmkvAhJuDndnoAiftou4V84okAGclop4U/jYACZDTxrYWP0gkxVfAm/W//GLZpxIzwIN0Hn8dw0B+IWkZmQmRsj2HfhwokEklHfNCCiQCRgAR7YyhQVRVTCKCzP4Y5zBBE0t0zY3Q8oQaBqqAMlVEcgVQd9706zGirAFium8HXumlMIeMwqQCInju+2+uB6MRENupdpMt8pRlHZyuAW0F+Mb6XSIVqtxjD+iVmVqqystLEzFTGT92YqRaXpNT5eTVjeJhbALPnrTxLUZUKZsgxcNm64hAOYisT/xhF+oKTGU5RegtC3Rt6eEDi/QnIevdTx9Md2EMmYBRmCQR1026FCGQQJJExsRUqgkMGaWSbwYLnoO4T6VgpbQbdELPMBAHWWrhYrcxXnYgAsatPWygkFCBD4K62MAsOTqA6szYRPpsu6e6Y8mPiVrBMNuGIMrgwBUu4p2DgG1Ownu6hpuTv7hScefHAzAC/yRRw5U5pALMbJ4AUALvHSZhxgHPXTsHcdWD1GadAHr9avP+c0wCr7263Df8ASLwXWHWs+KIAAAAHdElNRQfYBQEBODPr Organization: The Debian Project User-Agent: NeoMutt/20170113 (1.7.2) Hi, TL;DR: I recommend to just complete all packages upon "apt list --upgradable ". Oliver Kiddle wrote: > On 26 Jul, "Hauser, Felix (MRT)" wrote: > > just discovered the Z-shell and so far it really makes my life a little > > bit easier! The only issue I have with it is the completion of options > > for the apt command. So e.g.: > > > > apt list --u > > > > won't autocomplete to > > > > apt list --upgradeable > > > > which is easily done in the normal bash file. Should be easy in zsh, too, as the number of long options behind "apt list" isn't that big IIRC. > It's not clear from the man page whether the three options can be > combined with the glob(7) patterns for matching packages (as per the > patch below) or whether they need to be standalone. Indeed. Just from testing, there are additional filters possible: → apt list --installed 'z*' Listing... Done zathura-cb/stable,now 0.1.8-2 amd64 [installed,automatic] zathura-djvu/stable,now 0.2.8-1 amd64 [installed,automatic] […] zsh/stable,now 5.7.1-1 amd64 [installed,automatic] zutils/stable,now 1.8-3+b10 amd64 [installed,automatic] zziplib-bin/stable,now 0.13.62-3.2 amd64 [installed] zzuf/stable,now 0.15-1+b1 amd64 [installed] → But I think the primary issue of Felix is that not even the (rather unambiguous) options are completed. > The option should probably modify whether it is calling _deb_packages > with "avail", "installed", "uninstalled" or some other package set. If > you let me know what the relevant package set argument should be for > each option, then it is easy to do that. It makes sense that "apt list --installed " only completes installed packages as it will only list these anyway. It makes sense that "apt list --upgradable " (and "apt list --upgradeable ") only completes packages as it will only list these anyway. And "apt list --all-versions " should probably complete all packages. Daniel Shahaf wrote: > Hauser, Felix (MRT) wrote on Tue, 30 Jul 2019 11:50 +00:00: > > --upgradeable Do not know the option for this one. Result should be a > > list of all packages that can be updated by "apt upgrade". > > «aptitude search -F %p '?upgradable'» would print the right set of > packages, I think, but aptitude isn't part of a minimal installation so > can't be assumed available. Correct. Don't expect it to be there, it's no more installed by default. (Saying that with my "apt+aptitude team" member hat on, although I'm mostly only working on aptitude. :-) It seems obvious that "apt list --installed " should be completed with what "apt list --installed" outputs and "apt list --upgradable " and "apt list --upgradeable " with what "apt list --upgradeable" outputs. But: "apt" output is not yet considered to be stable and hence emits the following warning on STDERR when used inside a pipe or similar: WARNING: apt does not have a stable CLI interface. Use with caution in scripts. > I'm not sure what's the best way to answer this question on a minimal > installation. One _could_ parse the output of «apt-cache policy \*», > but I hope there's a better way... Currently I don't know any efficient _and_ scriptable method to do that. (Calling "apt-cache policy \*" to see if it's installed or upgradeable is the only method which comes to my mind, too, but also rather slow and inefficient. > Cc += Debian zsh packagers. Thanks. I read Felix initial mail, but just adding three hard coded long options seemed rather trivial... > tl;dr: What apt(7) command generates the right set of packages to be > completed after «apt list --upgradable »? "apt list --upgradable", but see above. Officially, there is currently no scriptable interface which offers that. aptitude-like pattern matching is planned for apt/apt-get/apt-cache as well, but not yet there. And parsing /var/lib/apt/lists/* is explicitly discouraged as the format might change without notice. (Zsh seems to do that somewhere else already and I get according warnings when in building the zsh package for Debian: https://lintian.debian.org/tags/uses-dpkg-database-directly.html) So we basically have these options: * Use "apt list --" and have to adapt quickly when the output format changes. * Parse the output of "apt-cache policy \*". (Probably the best way if we want to really only list upgradable packages there.) * Parse /var/lib/apt/archives/*.packages (format might change over time, too), /etc/apt/preferences and /etc/apt/preferences.d/*. * Completely ignore any "apt list" option and just complete all known packages. This seems to be a easily done solution and I consider it valid, because it is a valid call to pass not upgradable or installed packages even with --installed or --upgradable: → apt list --installed systemd zsh Listing... Done zsh/stable,now 5.7.1-1 amd64 [installed,automatic] → (i.e. in this example, systemd is not installed and zsh is installed.) Installed packages are easier to generated as they can be queried with dpkg-query which has options for machine-readable formatting. Regards, Axel -- ,''`. | Axel Beckert , https://people.debian.org/~abe/ : :' : | Debian Developer, ftp.ch.debian.org Admin `. `' | 4096R: 2517 B724 C5F6 CA99 5329 6E61 2FF9 CD59 6126 16B5 `- | 1024D: F067 EA27 26B9 C3FC 1486 202E C09E 1D89 9593 0EDE