Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #195696 > unrolled thread
| Started by | Richard Hector <richard@walnut.gen.nz> |
|---|---|
| First post | 2018-05-14 08:10 +0200 |
| Last post | 2018-05-14 12:00 +0200 |
| Articles | 11 — 4 participants |
Back to article view | Back to linux.debian.user
ssh config "Include" and bash completion Richard Hector <richard@walnut.gen.nz> - 2018-05-14 08:10 +0200
Re: ssh config "Include" and bash completion john doe <johndoe65534@mail.com> - 2018-05-14 10:50 +0200
Re: ssh config "Include" and bash completion Richard Hector <richard@walnut.gen.nz> - 2018-05-14 11:40 +0200
Re: ssh config "Include" and bash completion Javier Barroso <javibarroso@gmail.com> - 2018-05-14 12:00 +0200
Re: ssh config "Include" and bash completion Javier Barroso <javibarroso@gmail.com> - 2018-05-14 12:00 +0200
Re: ssh config "Include" and bash completion Richard Hector <richard@walnut.gen.nz> - 2018-05-14 12:30 +0200
Re: ssh config "Include" and bash completion Greg Wooledge <wooledg@eeg.ccf.org> - 2018-05-14 15:30 +0200
Re: ssh config "Include" and bash completion Greg Wooledge <wooledg@eeg.ccf.org> - 2018-05-14 15:40 +0200
Re: ssh config "Include" and bash completion Javier Barroso <javibarroso@gmail.com> - 2018-05-14 16:00 +0200
Re: ssh config "Include" and bash completion Javier Barroso <javibarroso@gmail.com> - 2018-05-14 15:40 +0200
Re: ssh config "Include" and bash completion Richard Hector <richard@walnut.gen.nz> - 2018-05-14 12:00 +0200
| From | Richard Hector <richard@walnut.gen.nz> |
|---|---|
| Date | 2018-05-14 08:10 +0200 |
| Subject | ssh config "Include" and bash completion |
| Message-ID | <vPeQh-4Jt-3@gated-at.bofh.it> |
[Multipart message — attachments visible in raw view] — view raw
Hi all, I recently started using the Include directive in my .ssh/config file - so all the definitions are now in .ssh/config.d/. Now bash completion of hostnames no longer works. Is this expected behaviour? Anyone know how to fix it, without reverting to a single file? I couldn't work out how to filter down a web search to find anything useful :-( Cheers, Richard
[toc] | [next] | [standalone]
| From | john doe <johndoe65534@mail.com> |
|---|---|
| Date | 2018-05-14 10:50 +0200 |
| Message-ID | <vPhl7-61U-11@gated-at.bofh.it> |
| In reply to | #195696 |
On 5/14/2018 8:09 AM, Richard Hector wrote: > Hi all, > > I recently started using the Include directive in my .ssh/config file - > so all the definitions are now in .ssh/config.d/. > > Now bash completion of hostnames no longer works. Is this expected > behaviour? Anyone know how to fix it, without reverting to a single file? > The only work around I can think of is: $ cat ~/.ssh/config host x include ~/.config.d/x $ cat ~/.ssh/config.d/x hostname x.example.com -- John Doe
[toc] | [prev] | [next] | [standalone]
| From | Richard Hector <richard@walnut.gen.nz> |
|---|---|
| Date | 2018-05-14 11:40 +0200 |
| Message-ID | <vPi7v-6wo-5@gated-at.bofh.it> |
| In reply to | #195701 |
[Multipart message — attachments visible in raw view] — view raw
On 14/05/18 20:49, john doe wrote: > On 5/14/2018 8:09 AM, Richard Hector wrote: >> Hi all, >> >> I recently started using the Include directive in my .ssh/config file - >> so all the definitions are now in .ssh/config.d/. >> >> Now bash completion of hostnames no longer works. Is this expected >> behaviour? Anyone know how to fix it, without reverting to a single file? >> > > The only work around I can think of is: > > $ cat ~/.ssh/config > host x > include ~/.config.d/x > > $ cat ~/.ssh/config.d/x > hostname x.example.com > Meaning all my hosts need to be specified in both places? Not really convenient. I don't actually use one file per host; I use one per 'group' - generally a client, or perhaps a vm or container host. I assume there's a way to modify the bash completion config, but I haven't looked at that. (Now I have, and it's ... going to require further study.) Richard
[toc] | [prev] | [next] | [standalone]
| From | Javier Barroso <javibarroso@gmail.com> |
|---|---|
| Date | 2018-05-14 12:00 +0200 |
| Message-ID | <vPiqS-6CI-15@gated-at.bofh.it> |
| In reply to | #195702 |
On Mon, May 14, 2018 at 11:51 AM, Javier Barroso <javibarroso@gmail.com> wrote:
> Hello Hector,
>
> It work for me:
>
> $ grep "Include\|testing" /etc/ssh/ssh_config ; cat /etc/ssh/ssh.d/test
> Include /etc/ssh/ssh.d/test
> Host testing
> Hostname 1.1.1.1
>
> $ ssh test<TAB> => testing
> $ dpkg -l bash-completion
> Deseado=desconocido(U)/Instalar/eliminaR/Purgar/retener(H)
> | Estado=No/Inst/ficheros-Conf/desempaqUetado/medio-conF/medio-inst(H)/espera-disparo(W)/pendienTe-disparo
> |/ Err?=(ninguno)/requiere-Reinst (Estado,Err: mayúsc.=malo)
> ||/ Nombre Versión Arquitectura
> Descripción
> +++-===============================-====================-====================-====================================================================
> ii bash-completion 1:2.8-1 all
> programmable completion for the bash shell
>
> At bash_completioni script:
>
> $ grep Inclu /usr/share/bash-completion/bash_completion -A10
> # This function look for the "Include" keyword in ssh config files and include
> # them recursively adding each result to the config variable
> _included_ssh_config_files()
> {
> [[ $# -lt 1 ]] && echo "error: $FUNCNAME: missing mandatory argument CONFIG"
> local configfile i f
> configfile=$1
> local included=$( command sed -ne
> 's/^[[:blank:]]*[Ii][Nn][Cc][Ll][Uu][Dd][Ee][[:blank:]]\{1,\}\([^#%]*\)\(#.*\)\{0,1\}$/\1/p'
> "${configfile}" )
> for i in ${included[@]}; do
> # Check the origin of $configfile to complete relative
> included paths on included
> # files according to ssh_config(5):
> --
> # The Included file is processed to look for Included
> files in itself
> _included_ssh_config_files $f
> fi
> done
> done
> } # _included_ssh_config_files()
>
>
> Regards
>
> On Mon, May 14, 2018 at 11:32 AM, Richard Hector <richard@walnut.gen.nz> wrote:
>> On 14/05/18 20:49, john doe wrote:
>>> On 5/14/2018 8:09 AM, Richard Hector wrote:
>>>> Hi all,
>>>>
>>>> I recently started using the Include directive in my .ssh/config file -
>>>> so all the definitions are now in .ssh/config.d/.
>>>>
>>>> Now bash completion of hostnames no longer works. Is this expected
>>>> behaviour? Anyone know how to fix it, without reverting to a single file?
>>>>
>>>
>>> The only work around I can think of is:
>>>
>>> $ cat ~/.ssh/config
>>> host x
>>> include ~/.config.d/x
>>>
>>> $ cat ~/.ssh/config.d/x
>>> hostname x.example.com
>>>
>>
>> Meaning all my hosts need to be specified in both places? Not really
>> convenient.
>>
>> I don't actually use one file per host; I use one per 'group' -
>> generally a client, or perhaps a vm or container host.
>>
>> I assume there's a way to modify the bash completion config, but I
>> haven't looked at that. (Now I have, and it's ... going to require
>> further study.)
>>
>> Richard
>>
Sorry for the top posting (and this second mail :( )
[toc] | [prev] | [next] | [standalone]
| From | Javier Barroso <javibarroso@gmail.com> |
|---|---|
| Date | 2018-05-14 12:00 +0200 |
| Message-ID | <vPiqS-6CI-17@gated-at.bofh.it> |
| In reply to | #195702 |
Hello Hector,
It work for me:
$ grep "Include\|testing" /etc/ssh/ssh_config ; cat /etc/ssh/ssh.d/test
Include /etc/ssh/ssh.d/test
Host testing
Hostname 1.1.1.1
$ ssh test<TAB> => testing
$ dpkg -l bash-completion
Deseado=desconocido(U)/Instalar/eliminaR/Purgar/retener(H)
| Estado=No/Inst/ficheros-Conf/desempaqUetado/medio-conF/medio-inst(H)/espera-disparo(W)/pendienTe-disparo
|/ Err?=(ninguno)/requiere-Reinst (Estado,Err: mayúsc.=malo)
||/ Nombre Versión Arquitectura
Descripción
+++-===============================-====================-====================-====================================================================
ii bash-completion 1:2.8-1 all
programmable completion for the bash shell
At bash_completioni script:
$ grep Inclu /usr/share/bash-completion/bash_completion -A10
# This function look for the "Include" keyword in ssh config files and include
# them recursively adding each result to the config variable
_included_ssh_config_files()
{
[[ $# -lt 1 ]] && echo "error: $FUNCNAME: missing mandatory argument CONFIG"
local configfile i f
configfile=$1
local included=$( command sed -ne
's/^[[:blank:]]*[Ii][Nn][Cc][Ll][Uu][Dd][Ee][[:blank:]]\{1,\}\([^#%]*\)\(#.*\)\{0,1\}$/\1/p'
"${configfile}" )
for i in ${included[@]}; do
# Check the origin of $configfile to complete relative
included paths on included
# files according to ssh_config(5):
--
# The Included file is processed to look for Included
files in itself
_included_ssh_config_files $f
fi
done
done
} # _included_ssh_config_files()
Regards
On Mon, May 14, 2018 at 11:32 AM, Richard Hector <richard@walnut.gen.nz> wrote:
> On 14/05/18 20:49, john doe wrote:
>> On 5/14/2018 8:09 AM, Richard Hector wrote:
>>> Hi all,
>>>
>>> I recently started using the Include directive in my .ssh/config file -
>>> so all the definitions are now in .ssh/config.d/.
>>>
>>> Now bash completion of hostnames no longer works. Is this expected
>>> behaviour? Anyone know how to fix it, without reverting to a single file?
>>>
>>
>> The only work around I can think of is:
>>
>> $ cat ~/.ssh/config
>> host x
>> include ~/.config.d/x
>>
>> $ cat ~/.ssh/config.d/x
>> hostname x.example.com
>>
>
> Meaning all my hosts need to be specified in both places? Not really
> convenient.
>
> I don't actually use one file per host; I use one per 'group' -
> generally a client, or perhaps a vm or container host.
>
> I assume there's a way to modify the bash completion config, but I
> haven't looked at that. (Now I have, and it's ... going to require
> further study.)
>
> Richard
>
[toc] | [prev] | [next] | [standalone]
| From | Richard Hector <richard@walnut.gen.nz> |
|---|---|
| Date | 2018-05-14 12:30 +0200 |
| Message-ID | <vPiTU-71u-1@gated-at.bofh.it> |
| In reply to | #195706 |
[Multipart message — attachments visible in raw view] — view raw
On 14/05/18 21:51, Javier Barroso wrote: > Hello Hector, > > It work for me: > > $ grep "Include\|testing" /etc/ssh/ssh_config ; cat /etc/ssh/ssh.d/test > Include /etc/ssh/ssh.d/test > Host testing > Hostname 1.1.1.1 > > $ ssh test<TAB> => testing > $ dpkg -l bash-completion > Deseado=desconocido(U)/Instalar/eliminaR/Purgar/retener(H) > | Estado=No/Inst/ficheros-Conf/desempaqUetado/medio-conF/medio-inst(H)/espera-disparo(W)/pendienTe-disparo > |/ Err?=(ninguno)/requiere-Reinst (Estado,Err: mayúsc.=malo) > ||/ Nombre Versión Arquitectura > Descripción > +++-===============================-====================-====================-==================================================================== > ii bash-completion 1:2.8-1 all > programmable completion for the bash shell Ah, yep - so you've got the newer version from buster or sid, presumably. I'm on stretch. Good to know that buster will fix it :-) I guess I could request a backport, but it's probably not worth it. Richard
[toc] | [prev] | [next] | [standalone]
| From | Greg Wooledge <wooledg@eeg.ccf.org> |
|---|---|
| Date | 2018-05-14 15:30 +0200 |
| Message-ID | <vPlI5-dI-1@gated-at.bofh.it> |
| In reply to | #195706 |
> local included=$( command sed -ne
> 's/^[[:blank:]]*[Ii][Nn][Cc][Ll][Uu][Dd][Ee][[:blank:]]\{1,\}\([^#%]*\)\(#.*\)\{0,1\}$/\1/p'
> "${configfile}" )
So, "included" is a string variable containing the ouput of sed.
If I'm reading that regex correctly, there'll be one pathname per line.
> for i in ${included[@]}; do
But then the function attempts to treat the string variable as an array,
and then attempts to iterate over the "array" using an unquoted expansion.
Code like this is one reason why I do not use bash-completion. Any time
it doesn't fail is just a lucky coincidence.
In this particular instance, it "works" so long as each pathname in
sed's output contains NO whitespace and NO globbing characters. The
array syntax is a total red herring, though -- you get the same result
(success or failure) just by expanding the string variable with regular
string expansion syntax.
wooledg:~$ included=$'/foo/bar\n/Program Files/junk'
wooledg:~$ args ${included[@]}
3 args: </foo/bar> </Program> <Files/junk>
wooledg:~$ args $included
3 args: </foo/bar> </Program> <Files/junk>
A correct implementation would have "included" be a real array variable,
initialized by splitting the sed output on newlines, so that each
pathname becomes one array element. Then, a *correct* array expansion
(with double quotes) would work:
wooledg:~$ included=(/foo/bar "/Program Files/junk")
wooledg:~$ args "${included[@]}"
2 args: </foo/bar> </Program Files/junk>
I don't know whether bash-completion is targeting bash 4.x exclusively,
or older bash versions. If it's targeting bash 4.x then it could use
mapfile to initialize the array from sed's output. Otherwise, it needs
a loop.
[toc] | [prev] | [next] | [standalone]
| From | Greg Wooledge <wooledg@eeg.ccf.org> |
|---|---|
| Date | 2018-05-14 15:40 +0200 |
| Message-ID | <vPlRL-gH-13@gated-at.bofh.it> |
| In reply to | #195719 |
On Mon, May 14, 2018 at 03:29:22PM +0200, Javier Barroso wrote: > Maybe you can improve the script talking / sendind pull request? with > ¿upstream? ¿https://github.com/scop/bash-completion? > > Thank you ! Not likely to happen. > == OFF TOPIC == > An annoying bug on debian (at least for me): > $ ls $(<TAB>bash: unexpected EOF while looking for matching `)' > bash: syntax error: unexpected end of file Does this happen with bash-completion disabled? Seems OK for me on stretch: wooledg:~$ ls $( Display all 1902 possibilities? (y or n) If the bug only happens with bash-completion enabled, then the bug is probably somewhere in bash-completion.
[toc] | [prev] | [next] | [standalone]
| From | Javier Barroso <javibarroso@gmail.com> |
|---|---|
| Date | 2018-05-14 16:00 +0200 |
| Message-ID | <vPmb9-nd-33@gated-at.bofh.it> |
| In reply to | #195721 |
Hello Greg, On Mon, May 14, 2018 at 3:35 PM, Greg Wooledge <wooledg@eeg.ccf.org> wrote: > On Mon, May 14, 2018 at 03:29:22PM +0200, Javier Barroso wrote: >> Maybe you can improve the script talking / sendind pull request? with >> żupstream? żhttps://github.com/scop/bash-completion? >> >> Thank you ! > > Not likely to happen. ok, only was a suggest > >> == OFF TOPIC == >> An annoying bug on debian (at least for me): >> $ ls $(<TAB>bash: unexpected EOF while looking for matching `)' >> bash: syntax error: unexpected end of file > > Does this happen with bash-completion disabled? Seems OK for me on > stretch: > > wooledg:~$ ls $( > Display all 1902 possibilities? (y or n) > > If the bug only happens with bash-completion enabled, then the bug is > probably somewhere in bash-completion. > Yes, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=742466 I think I saw that the bug was fixed at upstream, but now I am not able to find the fix Thanks !
[toc] | [prev] | [next] | [standalone]
| From | Javier Barroso <javibarroso@gmail.com> |
|---|---|
| Date | 2018-05-14 15:40 +0200 |
| Message-ID | <vPlRL-gH-15@gated-at.bofh.it> |
| In reply to | #195719 |
Hello Greg,
On Mon, May 14, 2018 at 3:19 PM, Greg Wooledge <wooledg@eeg.ccf.org> wrote:
>> local included=$( command sed -ne
>> 's/^[[:blank:]]*[Ii][Nn][Cc][Ll][Uu][Dd][Ee][[:blank:]]\{1,\}\([^#%]*\)\(#.*\)\{0,1\}$/\1/p'
>> "${configfile}" )
>
> So, "included" is a string variable containing the ouput of sed.
>
> If I'm reading that regex correctly, there'll be one pathname per line.
>
>> for i in ${included[@]}; do
>
> But then the function attempts to treat the string variable as an array,
> and then attempts to iterate over the "array" using an unquoted expansion.
>
> Code like this is one reason why I do not use bash-completion. Any time
> it doesn't fail is just a lucky coincidence.
>
> In this particular instance, it "works" so long as each pathname in
> sed's output contains NO whitespace and NO globbing characters. The
> array syntax is a total red herring, though -- you get the same result
> (success or failure) just by expanding the string variable with regular
> string expansion syntax.
>
> wooledg:~$ included=$'/foo/bar\n/Program Files/junk'
> wooledg:~$ args ${included[@]}
> 3 args: </foo/bar> </Program> <Files/junk>
> wooledg:~$ args $included
> 3 args: </foo/bar> </Program> <Files/junk>
>
> A correct implementation would have "included" be a real array variable,
> initialized by splitting the sed output on newlines, so that each
> pathname becomes one array element. Then, a *correct* array expansion
> (with double quotes) would work:
>
> wooledg:~$ included=(/foo/bar "/Program Files/junk")
> wooledg:~$ args "${included[@]}"
> 2 args: </foo/bar> </Program Files/junk>
>
> I don't know whether bash-completion is targeting bash 4.x exclusively,
> or older bash versions. If it's targeting bash 4.x then it could use
> mapfile to initialize the array from sed's output. Otherwise, it needs
> a loop.
>
Maybe you can improve the script talking / sendind pull request? with
¿upstream? ¿https://github.com/scop/bash-completion?
Thank you !
== OFF TOPIC ==
An annoying bug on debian (at least for me):
$ ls $(<TAB>bash: unexpected EOF while looking for matching `)'
bash: syntax error: unexpected end of file
[toc] | [prev] | [next] | [standalone]
| From | Richard Hector <richard@walnut.gen.nz> |
|---|---|
| Date | 2018-05-14 12:00 +0200 |
| Message-ID | <vPiqS-6CI-9@gated-at.bofh.it> |
| In reply to | #195696 |
[Multipart message — attachments visible in raw view] — view raw
On 14/05/18 18:09, Richard Hector wrote: > Hi all, > > I recently started using the Include directive in my .ssh/config file - > so all the definitions are now in .ssh/config.d/. > > Now bash completion of hostnames no longer works. Is this expected > behaviour? Anyone know how to fix it, without reverting to a single file? > > I couldn't work out how to filter down a web search to find anything > useful :-( Aha. There's a debian bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=834695 which refers to a solved upstream bug: https://github.com/scop/bash-completion/issues/70 ... so I guess I just have to wait for it to get to debian, probably in buster. In the meantime, I've modified /usr/share/bash-completion/bash_completion to suit my own needs (diff attached). Richard
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.user
csiph-web