attaching a patch. I think I tested everything I changed. I replaced the loop over ls output with grep -l | sed.
I made a bunch of overall changes and improvements to the script, too. When completing an empty word, instead of returning the full list of all available packages, all PIDs, and all files in the current directory, list just symptoms and made-up stand-in describing what arguments it accepts Completion doesn't list short options, just the long-option version. If you don't know what option you want, a letter doesn't tell you anything. $ apport-bug [TAB] audio dist-upgrade storage #buggy-file# --help --tag #buggy-package# release-upgrade ubuntu-release-upgrader #buggy-process-id# --save --version display security --window File and directory completion via _filedir, compopt -o dirnames fallback, or complete -f -d, never via complete -G "$cur*" or anything similarly horrible that will break with spaces in filenames. Also tidied up the functions. I think the point of some code duplication was to special-case completing the bare command, and only list --help and --version if we were completing the first argument. (which was kind of moot when completion output also included something like 40k package names...) Could still do that by checking $cword. ** Patch added: "several fixes: don't break with aliased ls, major speed improvements, keep results small when completing an empty word, and handle spaces" https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1221503/+attachment/4272391/+files/apport-completion.pjc.patch ** Changed in: apport (Ubuntu) Status: New => In Progress -- You received this bug notification because you are a member of Ubuntu Touch seeded packages, which is subscribed to apport in Ubuntu. https://bugs.launchpad.net/bugs/1221503 Title: completion with ubuntu-bug complains about missing release-upgrade.py Status in apport package in Ubuntu: In Progress Bug description: To reproduce the problem, type this command at a shell prompt (DO NOT PRESS ENTER AFTERWARD): $ ubuntu-bug and with the cursor at the end of the line, press the TAB key. The following errors appear: egrep: /usr/share/apport/symptoms/dist-upgrade.py@: No such file or directory egrep: /usr/share/apport/symptoms/release-upgrade.py@: No such file or directory If you clear the completion rules with "complete -r", this problem goes away. ProblemType: Bug DistroRelease: Ubuntu 13.04 Package: bash-completion 1:2.0-1ubuntu3 ProcVersionSignature: Ubuntu 3.8.0-29.42-generic 3.8.13.5 Uname: Linux 3.8.0-29-generic x86_64 ApportVersion: 2.9.2-0ubuntu8.3 Architecture: amd64 Date: Thu Sep 5 22:04:37 2013 InstallationDate: Installed on 2013-08-31 (5 days ago) InstallationMedia: Ubuntu 13.04 "Raring Ringtail" - Release amd64 (20130424) MarkForUpload: True PackageArchitecture: all SourcePackage: bash-completion UpgradeStatus: No upgrade log present (probably fresh install) To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1221503/+subscriptions -- Mailing list: https://launchpad.net/~touch-packages Post to : touch-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~touch-packages More help : https://help.launchpad.net/ListHelp