#653386 bash-completion doesn't commands not first on line

#653386#5
Date:
2011-12-27 15:27:01 UTC
From:
To:
The current "stable" version of bash-completion does not do
command completion in many of the places where something else
prefixes the command, for example:

su johndoe -c sor<tab>
sh -c sor<tab>
bash -c sor<tab>
fakeroot sor<tab>
LC_ALL=C sor<tab>

etc. etc.

Expected result:

sor<tab> completes to sort in all 5 cases

Actual result:

Only the fakeroot sor<tab> case completes to fakeroot sort

sor<tab> does not complete to sort unless I happen to have a
file by that name in the current dir (or a user by that name for
su!).

(I know the LC_ALL=C variant has its own bug report with a claim
that this is somehow a bug in bash, but the others cannot be
attributed to that).

These used to work in the bash-completion that was part of the
bash package a few years back.

This bug is also present in oldstable (lenny).

#653386#10
Date:
2018-12-22 02:07:35 UTC
From:
To:
Current unstable (2.8-4) still has this problem.

Completions for su are shipped by util-linux:

  # dpkg --search completions/su
  util-linux: /usr/share/bash-completion/completions/su

I'll forward this bug report to them, with a suggestion (see below)
on how to fix it.
https://github.com/gftg85/bash-completion/commit/d317efc82e41c5a58cd7712785a23439f7bc3fae

The fix for sh does not work for bash, because bash uses the _longopt
completion function, which is shared between many other commands, so I
have to think of a way to work around this.

These work with bash-completion 1:2.8-4.


Kind regards.