Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] Updated _aptitude zsh completion to cope with changed --help/-h output of aptitude 0.7.5



Hi,

the format of aptitude's --help/-h output slightly changed with the
0.7.5 release which caused the completion of subcommands to stop
working in zsh. This has been originally reported in Debian as
https://bugs.debian.org/807906

I've applied the following patch to Debian's zsh package in git,
verified that it works there and will upload it to Debian Unstable as
well as push it to the zsh git repository at SF. The patch should make
zsh work with both, the old and the new output.

Index: zsh/Completion/Debian/Command/_aptitude
===================================================================
--- zsh.orig/Completion/Debian/Command/_aptitude	2015-09-08 23:39:06.026975805 +0200
+++ zsh/Completion/Debian/Command/_aptitude	2015-12-26 19:26:14.681265798 +0100
@@ -80,7 +80,7 @@
 
 case $state in
   cmds)
-    cmds=( ${${(M)${(f)"$(LC_ALL=C _call_program commands aptitude -h 2>/dev/null)"}:#* - *}/(#b) (*[^ ]) #- (*)/$match[1]:$match[2]:l})
+    cmds=( ${${(M)${(f)"$(LC_ALL=C _call_program commands aptitude -h 2>/dev/null)"}:# [^- ][^ ]## *}/(#b) ([^ ]##) ##(- )#([^- ]*)/$match[1]:$match[3]:l})
 
     _describe -t commands 'aptitude command' cmds && ret=0
   ;;

For reference, here's the relevant part of the old and new output:

Old output:

→ aptitude -h
aptitude 0.6.11
Usage: aptitude [-S fname] [-u|-i]
       aptitude [options] <action> ...
  Actions (if none is specified, aptitude will enter interactive mode):

 install      - Install/upgrade packages.
 remove       - Remove packages.
 purge        - Remove packages and their configuration files.
 hold         - Place packages on hold.
 unhold       - Cancel a hold command for a package.
 markauto     - Mark packages as having been automatically installed.
 unmarkauto   - Mark packages as having been manually installed.
 forbid-version - Forbid aptitude from upgrading to a specific package version.
 update       - Download lists of new/upgradable packages.
 safe-upgrade - Perform a safe upgrade.
 full-upgrade - Perform an upgrade, possibly installing and removing packages.
 build-dep    - Install the build-dependencies of packages.
 forget-new   - Forget what packages are "new".
 search       - Search for a package by name and/or expression.
 show         - Display detailed information about a package.
 versions     - Displays the versions of specified packages.
 clean        - Erase downloaded package files.
 autoclean    - Erase old downloaded package files.
 changelog    - View a package's changelog.
 download     - Download the .deb file for a package.
 reinstall    - Download and (possibly) reinstall a currently installed package.
 why          - Show the manually installed packages that require a package, or
                why one or more packages would require the given package.
 why-not      - Show the manually installed packages that lead to a conflict
                with the given package, or why one or more packages would
                lead to a conflict with the given package if installed.

  Options:
 -h             This help text.
 --no-gui       Do not use the GTK GUI even if available.
[…]

New output:

→ aptitude -h
aptitude 0.7.5
Usage: aptitude [-S fname] [-u|-i]
       aptitude [options] <action> ...

Actions (if none is specified, aptitude will enter interactive mode):

 install         Install/upgrade packages.
 remove          Remove packages.
 purge           Remove packages and their configuration files.
 hold            Place packages on hold.
 unhold          Cancel a hold command for a package.
 markauto        Mark packages as having been automatically installed.
 unmarkauto      Mark packages as having been manually installed.
 forbid-version  Forbid aptitude from upgrading to a specific package version.
 update          Download lists of new/upgradable packages.
 safe-upgrade    Perform a safe upgrade.
 full-upgrade    Perform an upgrade, possibly installing and removing packages.
 build-dep       Install the build-dependencies of packages.
 forget-new      Forget what packages are "new".
 search          Search for a package by name and/or expression.
 show            Display detailed information about a package.
 versions        Displays the versions of specified packages.
 clean           Erase downloaded package files.
 autoclean       Erase old downloaded package files.
 changelog       View a package's changelog.
 download        Download the .deb file for a package.
 reinstall       Reinstall a currently installed package.
 why             Explain why a particular package should be installed.
 why-not         Explain why a particular package cannot be installed.

 add-user-tag    Add user tag to packages/patterns.
 remove-user-tag Remove user tag from packages/patterns.

Options:
 -h              This help text.
 --no-gui        Do not use the GTK GUI even if available.
[…]

Main difference: no more dash inbetween subcommand and description.

		Kind regards, Axel
-- 
/~\  Plain Text Ribbon Campaign                   | Axel Beckert
\ /  Say No to HTML in E-Mail and News            | abe@xxxxxxxxxxxxxxx  (Mail)
 X   See http://www.nonhtmlmail.org/campaign.html | abe@xxxxxxxxx (Mail+Jabber)
/ \  I love long mails: http://email.is-not-s.ms/ | http://abe.noone.org/ (Web)



Messages sorted by: Reverse Date, Date, Thread, Author