scop / bash-completion

Programmable completion functions for bash
GNU General Public License v2.0
2.9k stars 380 forks source link

fix(gdb): fix regression that fails to generate command names #1101

Closed akinomyoga closed 7 months ago

akinomyoga commented 7 months ago

The current version fails to generate any command names for the first word after the command name "gdb". This is a regression introduced in https://github.com/scop/bash-completion/pull/1086 and pointed out in the comment: https://github.com/scop/bash-completion/commit/73c5292b7a39a2f3d1ae01057e0afd3aa24c8a32#r138406647.

akinomyoga commented 7 months ago

Thank you! However, the CI doesn't seem to pass actually. In making the test, I assumed that awk would be always found in PATH, but it doesn't seem to work in the alpine container. I'll later take a look.

akinomyoga commented 7 months ago

but it doesn't seem to work in the alpine container. I'll later take a look.

https://github.com/scop/bash-completion/blob/ca8e2405ae49c927f9c9d312aa0efdde3d231bf2/completions/gdb#L30-L34

The find command in the alpine container doesn't have the operator -printf. According to POSIX [1], -mindepth is not POSIX, -maxdepth is not POSIX, -not is not POSIX, -executable is not POSIX, and -printf is not POSIX. Only -type out of the six operators used in this implementation is POSIX-compatible.

It didn't cause an error before because it's never been tested.

scop commented 7 months ago

I suppose we could use require_cmd=True and gdb as the test command.

akinomyoga commented 7 months ago

I suppose we could use require_cmd=True and gdb as the test command.

Ah, yeah. That is clever.