Luca Boccassi
2018-11-23 12:48:54 UTC
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 <***@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 &&
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 <***@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
2.19.1