Package: bash-completion
Version: 1:2.11-2
Severity: normal
Tags: patch
X-Debbugs-Cc: j.naum...@fu-berlin.de

Dear Maintainer,

The regular expressions in is_filelist which matches "well-known idioms
on bash scripts" currently matches the path to the bash-completion
script in the nitrokey-app package[1]:

    'data/bash-autocomplete/nitrokey-app' =~ /\s*complete.*-[A-Za-z].*/

This causes debian/nitrokey-app.bash-completion to be installed as
/usr/share/bash-completion/completions/nitrokey-app, which is not
useful.

I've attached a patch to fix the issue by requiring complete to follow a
line break or semicolon.  It obviously does not address the root of the
problem of reliably differentiating a list of paths from a Bash script.
(Which is not really possible, since a list of paths is a valid bash
script.)  But it may be a sufficient quick fix until/unless #785271 is
addressed.

Thanks for considering,
Kevin

[1]: 
https://salsa.debian.org/janluca-guest/nitrokey-app-debian/-/blob/master/debian/nitrokey-app.bash-completion


-- System Information:
Debian Release: bullseye/sid
  APT prefers testing-debug
  APT policy: (990, 'testing-debug'), (990, 'testing'), (500, 
'unstable-debug'), (500, 'testing-security'), (500, 'stable-debug'), (500, 
'unstable'), (101, 'experimental'), (1, 'experimental-debug')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.11.0 (SMP w/4 CPU threads)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

-- no debconf information
>From 77b328932fa429e2f3a6ac5e86707d88eb939856 Mon Sep 17 00:00:00 2001
Message-Id: 
<77b328932fa429e2f3a6ac5e86707d88eb939856.1615656992.git.ke...@kevinlocke.name>
From: Kevin Locke <ke...@kevinlocke.name>
Date: Sat, 13 Mar 2021 10:18:37 -0700
Subject: [PATCH] dh_bash-completion: Tighten is_filelist matching

The regular expressions in is_filelist which matches "well-known idioms
on bash scripts" currently matches the path to the bash-completion
script in the nitrokey-app package:

    'data/bash-autocomplete/nitrokey-app' =~ /\s*complete.*-[A-Za-z].*/

Avoid this by ensuring the is only matched when following a line break
or semicolon.

Signed-off-by: Kevin Locke <ke...@kevinlocke.name>
---
 debian/extra/debhelper/dh_bash-completion | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/extra/debhelper/dh_bash-completion 
b/debian/extra/debhelper/dh_bash-completion
index d1d9bf2e..d292ea87 100755
--- a/debian/extra/debhelper/dh_bash-completion
+++ b/debian/extra/debhelper/dh_bash-completion
@@ -75,7 +75,7 @@ sub is_filelist {
                #
                # - If we see an "if...then" construction in the file.  We
                #   take into account multi-line statements.
-               if (/\s*complete.*-[A-Za-z].*/
+               if (/(^|;)\s*complete.*-[A-Za-z].*/
                        || /\$\(.*\)/
                        || /\s*compgen.*-[A-Za-z].*/
                        || /\s*if.*;.*then/s) {
-- 
2.30.1

Reply via email to