Commit ab585cf
committed
Make BASH hook compatible with spaces in completion results
ZSH handles multi-word completion results correctly out of the box, but BASH needed
some prodding to stop it interpreting all space-delimited words as separate
suggestions. There are two parts to this fix:
- The addition of a local `IFS` variable was required to prevent splitting
from happening inside multi-word completions.
- Spaces needed to be manually escaped when quotes were missing as completing
as completion was otherwise dumping the raw result without escaping. I haven't
looked into how filename completion mode handles this without showing
backslashes in the completion result, but the behaviour here mirrors ZSH so
this isn't a huge problem.
Custom multi-word completions in BASH aren't particularly intuitive - these
threads were helpful while figuring this solution out:
https://stackoverflow.com/questions/26509260/bash-tab-completion-with-spaces
https://stackoverflow.com/questions/1146098/properly-handling-spaces-and-quotes-in-bash-completion
https://stackoverflow.com/questions/10652492/bash-autocompletion-how-to-pass-this-array-to-compgen-without-significant-whit1 parent 2488ee1 commit ab585cf
1 file changed
+8
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| |||
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
| |||
0 commit comments