X-Received: by 2002:a05:620a:2603:b0:72e:f333:8cc8 with SMTP id z3-20020a05620a260300b0072ef3338cc8mr160996qko.10.1676485540294; Wed, 15 Feb 2023 10:25:40 -0800 (PST) X-Received: by 2002:a05:6870:6487:b0:16a:acc6:ccf6 with SMTP id cz7-20020a056870648700b0016aacc6ccf6mr466013oab.282.1676485539886; Wed, 15 Feb 2023 10:25:39 -0800 (PST) Path: csiph.com!tncsrv06.tnetconsulting.net!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: gnu.bash.bug Date: Wed, 15 Feb 2023 10:25:39 -0800 (PST) In-Reply-To: <30605fd8-1b9c-4071-a08f-fdd64257d26dn@googlegroups.com> Injection-Info: google-groups.googlegroups.com; posting-host=5.182.110.182; posting-account=1QxalAoAAADvCk-YgIWuWGP1Fl6szJEU NNTP-Posting-Host: 5.182.110.182 References: <30605fd8-1b9c-4071-a08f-fdd64257d26dn@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Bash completion fails if command results from alias expansion From: GODSWILL DUKE Injection-Date: Wed, 15 Feb 2023 18:25:40 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 4000 Xref: csiph.com gnu.bash.bug:16895 On Tuesday, June 14, 2022 at 3:22:59 AM UTC-7, Tasos Papastylianou wrote: > Dear bash maintainers.=20 >=20 > I posted this at the SuperUser stackexchange forum (here: https://superus= er.com/q/1725872/717607), so please see that post too if you like (especial= ly if it generates separate conversaion, which it has not so far) but I tho= ught I might as well ask straight from the horses mouth and submit this as = a bug after all.=20 >=20 > There are several posts online (e.g. https://superuser.com/q/436314/71760= 7) suggesting workarounds for bash completing aliases whose commands have e= stablished completions defined.=20 >=20 > However, in the bash manual (i.e. man bash, currently using GNU bash, ver= sion 5.0.17), section Programmable Completion, it states that:=20 >=20 > > If there is no default compspec, bash attempts alias expansion on the c= ommand word as a final resort, and attempts to find a compspec for the comm= and word from any successful expansion.=20 >=20 > In other words one would have expected this to work:=20 >=20 > function foobar () { echo "Hello from foobar"; }=20 > function _foobar () { COMPREPLY=3D( foo bar baz ); } && complete -F _foob= ar foobar=20 > alias foo=3D'foobar'=20 >=20 > Typing `foobar[TAB][TAB]` autocompletes as expected.=20 >=20 > However, typing `foo[TAB][TAB]` does not work, and shows a default comple= tion instead.=20 >=20 > 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 man= ual 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?)=20 >=20 > 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.=20 >=20 > Also, I've checked the changelogs up to the latest version of Bash, as an= nounced here, but it doesn't seem to me this has been addressed.=20 >=20 > 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 bu= g, since it doesn't actually work as documented; and if it is not desired b= ehaviour, then perhaps that statement about completion of alias-expanded co= mmands should be removed from the bash man page.=20 >=20 > Best,=20 > Tasos hello