Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > gnu.bash.bug > #16895
| Newsgroups | gnu.bash.bug |
|---|---|
| Date | 2023-02-15 10:25 -0800 |
| References | <30605fd8-1b9c-4071-a08f-fdd64257d26dn@googlegroups.com> |
| Message-ID | <a728d774-a0f2-4517-9fa9-eeeaaf7f68efn@googlegroups.com> (permalink) |
| Subject | Re: Bash completion fails if command results from alias expansion |
| From | GODSWILL DUKE <dukegodswill2022@gmail.com> |
On Tuesday, June 14, 2022 at 3:22:59 AM UTC-7, Tasos Papastylianou wrote:
> Dear bash maintainers.
>
> I posted this at the SuperUser stackexchange forum (here: https://superuser.com/q/1725872/717607), so please see that post too if you like (especially if it generates separate conversaion, which it has not so far) but I thought I might as well ask straight from the horses mouth and submit this as a bug after all.
>
> There are several posts online (e.g. https://superuser.com/q/436314/717607) suggesting workarounds for bash completing aliases whose commands have established completions defined.
>
> However, in the bash manual (i.e. man bash, currently using GNU bash, version 5.0.17), section Programmable Completion, it states that:
>
> > If there is no default compspec, bash attempts alias expansion on the command word as a final resort, and attempts to find a compspec for the command word from any successful expansion.
>
> In other words one would have expected this to work:
>
> function foobar () { echo "Hello from foobar"; }
> function _foobar () { COMPREPLY=( foo bar baz ); } && complete -F _foobar foobar
> alias foo='foobar'
>
> Typing `foobar[TAB][TAB]` autocompletes as expected.
>
> However, typing `foo[TAB][TAB]` does not work, and shows a default completion instead.
>
> Given the linked posts suggesting workarounds, I don't think it's just me doing something wrong here. But then what does the quote from the bash manual actually refer to then? Am I misunderstanding the quote from the manual? Or is bash simply not doing what is says it should have been doing here? (i.e. is this simply a bug?)
>
> I note a nearly identical question was asked in the bash bug tracker back in 2011 (with yet another nice workaround: https://groups.google.com/g/gnu.bash.bug/c/gENuqpAUTUg/m/JpHbe7KmpGgJ), but the phrasing of that question implies that this was not mentioned in the manual back then, and I haven't seen any sign of addressing this issue on the official group page since.
>
> Also, I've checked the changelogs up to the latest version of Bash, as announced here, but it doesn't seem to me this has been addressed.
>
> I don't know if "completion of alias expanded commands" is a good idea or not, that's a matter for debate among the maintainers (I'm of a split mind myself!); but if it *is* intended behaviour, then I'm reporting it as a bug, since it doesn't actually work as documented; and if it is not desired behaviour, then perhaps that statement about completion of alias-expanded commands should be removed from the bash man page.
>
> Best,
> Tasos
hello
Back to gnu.bash.bug | Previous | Next — Previous in thread | Find similar
Bash completion fails if command results from alias expansion Tasos Papastylianou <tpapastylianou@gmail.com> - 2022-06-14 03:22 -0700 Re: Bash completion fails if command results from alias expansion GODSWILL DUKE <dukegodswill2022@gmail.com> - 2023-02-15 10:25 -0800
csiph-web