Package: bash Version: 5.2~rc1-1 Severity: normal Dear Maintainer,
It is not uncommon for completion functions to just try executing optional commands that might not be present. We do not want the regular command_not_found_handle behavior in those cases, as they are not the ones where a user should be notified that a command was not found. Output from the function may cause bogus completions, console trashing, and at least it adds some unnecessary delay to the command completion. Return early from the function when a completion function has been detected running. Use `COMP_CWORD` as the marker; PackageKit has been using it for 7+ years at time of writing. Refs https://github.com/PackageKit/PackageKit/pull/67 Refs https://bugzilla.redhat.com/1164410 -- System Information: Debian Release: bullseye/sid APT prefers focal-updates APT policy: (500, 'focal-updates'), (500, 'focal-security'), (500, 'focal'), (100, 'focal-backports') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 5.13.0-52-generic (SMP w/4 CPU cores) Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE=en_GB:en_US:en (charmap=UTF-8) Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages bash depends on: ii base-files 11ubuntu5.5 ii debianutils 4.9.1 ii libc6 2.31-0ubuntu9.9 ii libtinfo6 6.2-0ubuntu2 Versions of packages bash recommends: pn bash-completion <none> Versions of packages bash suggests: pn bash-doc <none> -- no debconf information
>From d1eabf80eba3b4fdfbf4bfddb7fd98492f4263ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.sky...@iki.fi> Date: Sun, 17 Jul 2022 22:35:59 +0300 Subject: [PATCH] fix(bashrc): skip command_not_found_handle within completions It is not uncommon for completion functions to just try executing optional commands that might not be present. We do not want the regular command_not_found_handle behavior in those cases, as they are not the ones where a user should be notified that a command was not found. Output from the function may cause bogus completions, console trashing, and at least it adds some unnecessary delay to the command completion. Return early from the function when a completion function has been detected running. Use `COMP_CWORD` as the marker; PackageKit has been using it for 7+ years at time of writing. Refs https://github.com/PackageKit/PackageKit/pull/67 Refs https://bugzilla.redhat.com/1164410 --- debian/etc.bash.bashrc | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/etc.bash.bashrc b/debian/etc.bash.bashrc index 7fabe82..06fb1e5 100644 --- a/debian/etc.bash.bashrc +++ b/debian/etc.bash.bashrc @@ -43,6 +43,7 @@ fi # if the command-not-found package is installed, use it if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then function command_not_found_handle { + [ -v COMP_CWORD ] && return 0 # skip within completion functions # check because c-n-f could've been removed in the meantime if [ -x /usr/lib/command-not-found ]; then /usr/lib/command-not-found -- "$1" -- 2.25.1