Commit 0c0b1b3
committed
Escape completion results for BASH before writing to stdout
In the previous commit I used `printf '%q'` in the BASH hook to handle escaping
unquoted strings, however this didn't handle escaping quote characters inside
strings where needed. This commit moves the responsibility of escaping completion
results into PHP to make the escaping logic testable and easier to maintain.
BASH supports automatic escaping/quoting in completion results only when the
`-o filenames` option is used to register a completion function. The `filenames`
option has behaviour that is incompatible with a generic completion handler,
such as appending a `/` on results that happen to match directory name in the CWD.
Unfortuntately this means we cannot use this functionality. There is no API to
change this behaviour as far as I've been able to see from the BASH docs and
source code.
ZSH handles escaping of completion functions perfectly fine out of the box.1 parent ab585cf commit 0c0b1b3
File tree
4 files changed
+138
-14
lines changed- src
- tests/Stecman/Component/Symfony/Console/BashCompletion
4 files changed
+138
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
80 | 127 | | |
81 | 128 | | |
82 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
46 | 56 | | |
47 | 57 | | |
48 | 58 | | |
| |||
101 | 111 | | |
102 | 112 | | |
103 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
104 | 130 | | |
105 | 131 | | |
106 | 132 | | |
| |||
132 | 158 | | |
133 | 159 | | |
134 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
135 | 177 | | |
136 | 178 | | |
137 | 179 | | |
| |||
202 | 244 | | |
203 | 245 | | |
204 | 246 | | |
| 247 | + | |
205 | 248 | | |
206 | 249 | | |
207 | 250 | | |
| |||
213 | 256 | | |
214 | 257 | | |
215 | 258 | | |
| 259 | + | |
216 | 260 | | |
217 | 261 | | |
218 | 262 | | |
219 | 263 | | |
220 | | - | |
221 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
222 | 269 | | |
223 | | - | |
| 270 | + | |
224 | 271 | | |
225 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
226 | 275 | | |
227 | 276 | | |
228 | 277 | | |
| |||
231 | 280 | | |
232 | 281 | | |
233 | 282 | | |
| 283 | + | |
234 | 284 | | |
235 | 285 | | |
236 | 286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | 71 | | |
77 | 72 | | |
78 | 73 | | |
| |||
156 | 151 | | |
157 | 152 | | |
158 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
159 | 157 | | |
160 | 158 | | |
161 | 159 | | |
| |||
Lines changed: 31 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
118 | 135 | | |
119 | 136 | | |
120 | 137 | | |
| |||
130 | 147 | | |
131 | 148 | | |
132 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
133 | 162 | | |
134 | 163 | | |
135 | 164 | | |
| |||
0 commit comments