Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14843

[PATCH] Fix custom program's completions when initial word is set

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Luca Boccassi <bluca@debian.org>
Newsgroups gnu.bash.bug
Subject [PATCH] Fix custom program's completions when initial word is set
Date Fri, 23 Nov 2018 12:48:54 +0000
Lines 49
Approved bug-bash@gnu.org
Message-ID <mailman.4494.1542977352.1284.bug-bash@gnu.org> (permalink)
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Transfer-Encoding 8bit
X-Trace usenet.stanford.edu 1542977353 24436 208.118.235.17 (23 Nov 2018 12:49:13 GMT)
X-Complaints-To action@cs.stanford.edu
Cc Luca Boccassi <bluca@debian.org>
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=telmV2iSxRvE7gk+k67t64mWysB5X75smA4wu4P9EdE=; b=EBrQbtsxYVZyKJm142RTW3zKcLpkVjjijauloH0Ly4I6oT2btj6uMoMtFLbFejFz5r hX3zx/I0AzR4GabxpQN3ngdEmK178WXuyIseoGoYFfqYga/ZFTZmkN9ypoCXruDzLth/ OxI0JF/XTk75EtygOahbUmObkAeewpFZDhYRdRbLzEcOxWChBFZP0uxolhJIW9dj/Yo8 iC6o40ts2j7a9bJtXOtFU456pxHwU6xoHGnnNqLW1kPrheZf30t7sdwyTehjkOM/nTGA kyXCd5hD7QpWJuc7+inVDgHPuf170BnkT3/rf1YBvFL2mECTt8mFq3kK3avlHaZxLLyr QOhQ==
X-Gm-Message-State AA+aEWbNjVVxGiXFP8BBLvFZjgOSvLFtdwO9cPazD0dOksTjor5dDb5P SOUSccYJbKj77yG491K6cgBWnltc
X-Google-Smtp-Source AFSGD/X/n7hlPdl6qxLU8qo04a1byCcyfKhoNs8o82cLKAXejImaLT3cyIuuwZVXCm3M+03wBUEz8A==
X-Received by 2002:adf:f8d2:: with SMTP id f18mr10596830wrq.265.1542977338627; Fri, 23 Nov 2018 04:48:58 -0800 (PST)
X-Mailer git-send-email 2.19.1
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy]
X-Received-From 209.85.221.43
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14843

Show key headers only | View raw


The change to fix mid-word initial completion inadvertently broke custom
command completion.
To reproduce:

cat > repro<<EOF
_repro()
{
  echo "completed"
}
EOF
source repro
complete -I -F _repro
git sho
      ^ tab, nothing happens

This is because if complete -I is set, iw_compspec will always be
non-null and therefore foundcs will always be set to false and bash
will ignore the result of programmable_completions().
The fix is to only override foundcs if both iw_compspec is not null
and we are not in command position.

Signed-off-by: Luca Boccassi <bluca@debian.org>
---
Dear Maintainer,

noticed this a bit too late after some more testing. This fix appears
to work, let me know if you'd like a different solution.
Thanks!

 bashline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bashline.c b/bashline.c
index d56cd79d..f2d17a70 100644
--- a/bashline.c
+++ b/bashline.c
@@ -1583,7 +1583,7 @@ attempt_shell_completion (text, start, end)
 	  /* command completion if programmable completion fails */
 	  /* If we have a completion for the initial word, we can prefer that */
 	  in_command_position = s == start && (iw_compspec || STREQ (n, text));	/* XXX */
-	  foundcs = foundcs && (iw_compspec == 0);
+	  foundcs = foundcs && (iw_compspec == 0 || in_command_position == 0);
 	}
       /* empty command name following command separator */
       else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0 &&
-- 
2.19.1

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] Fix custom program's completions when initial word is set Luca Boccassi <bluca@debian.org> - 2018-11-23 12:48 +0000

csiph-web