Fix Bash completion on Debian/Ubuntu #246

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants

Smylers commented Jan 2, 2013

Bash completion wasn't working on systems where the command is installed
as ack-grep, and in some cases sourcing the completion was giving an error
message.

In Shell || has lower precedence than |, so in the line setting
__ack_types only the second alternative, ack, had its help output filtered
through the Perl one-liner that extracts the options; on systems where the
command is called ack-grep (Debian and derivatives such as Ubuntu), the
__ack_types variable had the raw help output assigned.

This obviously made $__ack_types contain all sorts of things that aren't
types, so completing incorrectly.

And with the Bash shell option failglob set it also made loading Bash
completion (probably) yield this error message:

bash: no match: [OPTION]...

This is because the ack help text (which gets separated on spaces)
contains '[OPTION]...', and the square brackets are shell metacharacters,
trying to match a file in the current directory called O... or P... or
similar -- and most directories don't contain a file with any of those
names.

Fixed by adding parens, so either ack-grep or grep is invoked, then the
output of the chosen alternative filtered through the Perl one-liner.

Fix Bash completion on Debian/Ubuntu
Bash completion wasn't working on systems where the command is installed
as ack-grep, and in some cases sourcing the completion was giving an error
message.

In Shell || has lower precedence than |, so in the line setting
__ack_types only the second alternative, ack, had its help output filtered
through the Perl one-liner that extracts the options; on systems where the
command is called ack-grep (Debian and derivatives such as Ubuntu), the
__ack_types variable had the raw help output assigned.

This obviously made $__ack_types contain all sorts of things that aren't
types, so completing incorrectly.

And with the Bash shell option failglob set it also made loading Bash
completion (probably) yield this error message:

  bash: no match: [OPTION]...

This is because the ack help text (which gets separated on spaces)
contains '[OPTION]...', and the square brackets are shell metacharacters,
trying to match a file in the current directory called O... or P... or
similar -- and most directories don't contain a file with any of those
names.

Fixed by adding parens, so either ack-grep or grep is invoked, then the
output of the chosen alternative filtered through the Perl one-liner.
Collaborator

petdance commented Jan 2, 2013

I haven't looked at this yet, but will probably have to fold the same sorts of changes into ack2's bash completion as well.

Collaborator

hoelzro commented Aug 28, 2013

Mentioned in corresponding ack2 issue.

@hoelzro hoelzro closed this Aug 28, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment