GNOME Bugzilla – Bug 709426
nmcli bash completion does not work correctly with special characters/whitespace
Last modified: 2014-05-03 12:23:10 UTC
bash completion for nmcli with names that contains spaces does not work as expected. Assuming you have a connection name "Wireless Connection 1" See how the following cases fail: $ nmcli c show configured id Wir<TAB> $ nmcli c show configured id Wireless\ <TAB> $ nmcli c show configured id W'<TAB> Notice, that in standard bash this works correctly and as you would expect. Basically, _nmcli_list_nl does not work correctly. I don't know how to fix it. Anyone?
Created attachment 274256 [details] [review] [PATCH] enhance bash completion for connection names This patch fixes handling of connection names with spaces and quotes in the name.
Comment on attachment 274256 [details] [review] [PATCH] enhance bash completion for connection names > See e.g. http://stackoverflow.com/questions/1146098/properly-handling-spaces-and-quotes-in-bash-completion Did you try the simpler version further down the page? >+ local escaped_single_qoute="'\''" typo "qoute" (and where it's used below). Although, I don't think it needs that variable anyway... it seems like if you just replace the "\" with "\\" then you should be able to have the substitution be inline just like in the double-quote case.
Created attachment 274267 [details] [review] fixup! patch to 0001-cli-bash-completion-escape-spaces-in-profile-names-r.patch It improves the situation a lot, great. I would however apply the attached fixup!, because otherwise the syntax highlighting in VI got confused (at least for me). Things that still don't work are like nmcli connection show "W"ired\ Conn<TAB> results in nmcli connection show Wired Connection 1 anyway, it does improve a lot...
(In reply to comment #2) > (From update of attachment 274256 [details] [review]) > > See e.g. http://stackoverflow.com/questions/1146098/properly-handling-spaces-and-quotes-in-bash-completion > > Did you try the simpler version further down the page? > I tried with printf "%q\n". It solves some case, but not all. So it is not sufficient itself. > >+ local escaped_single_qoute="'\''" > > typo "qoute" (and where it's used below). > > Although, I don't think it needs that variable anyway... it seems like if you > just replace the "\" with "\\" then you should be able to have the substitution > be inline just like in the double-quote case. I fixed the typo. But, I prefer to have the variable there for readability, because putting the literal value makes the forest of slashes and quotes worse. (In reply to comment #3) > Created an attachment (id=274267) [details] [review] > fixup! patch to 0001-cli-bash-completion-escape-spaces-in-profile-names-r.patch > Squashed.
Created attachment 274371 [details] [review] [PATCH] enhance bash completion for connection names
Patch in comment #5 pushed to master as b911d66 cli/bash-completion: escape spaces in profile names (rh #1041901) (bgo #709426)
*** Bug 729454 has been marked as a duplicate of this bug. ***
Could you also apply this patch for Fedora 20?