File tree 1 file changed +22
-11
lines changed
src/Symfony/Component/Console/Resources
1 file changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -19,32 +19,43 @@ _sf_{{ COMMAND_NAME }}() {
19
19
local completecmd=(" $sf_cmd " " _complete" " -sbash" " -c$cword " " -S{{ VERSION }}" )
20
20
for w in ${words[@]} ; do
21
21
w=$( printf -- ' %b' " $w " )
22
- # remove quotes
22
+ # remove quotes from typed values
23
23
quote=" ${w: 0: 1} "
24
- if [ " $quote " == " ' " ]; then
24
+ if [ " $quote " == \' ]; then
25
25
w=" ${w% \' } "
26
26
w=" ${w# \' } "
27
- elif [ " $quote " == ' " ' ]; then
27
+ elif [ " $quote " == \" ]; then
28
28
w=" ${w% \" } "
29
29
w=" ${w# \" } "
30
30
fi
31
- completecmd+=(" -i$w " )
31
+ # empty values are ignored
32
+ if [ ! -z " $w " ]; then
33
+ completecmd+=(" -i$w " )
34
+ fi
32
35
done
33
36
34
37
local sfcomplete
35
38
if sfcomplete=$( ${completecmd[@]} 2>&1 ) ; then
36
39
local quote suggestions
37
40
quote=${cur: 0: 1}
38
- if [ " $quote " == " '" ]; then
41
+
42
+ # Use single quotes by default if suggestions contains backslash (FQCN)
43
+ if [ " $quote " == ' ' ] && [[ " $sfcomplete " =~ \\ ]]; then
44
+ quote=\'
45
+ fi
46
+
47
+ if [ " $quote " == \' ]; then
39
48
# single quotes: no additional escaping (does not accept ' in values)
40
49
suggestions=$( for s in $sfcomplete ; do printf $' %q%q%q\n ' " $quote " " $s " " $quote " ; done)
41
- elif [ " $quote " == ' " ' ]; then
50
+ elif [ " $quote " == \" ]; then
42
51
# double quotes: double escaping for \ $ ` "
43
- s=${s// \\ / \\\\ }
44
- s=${s// \$ / \\\$ }
45
- s=${s// \` / \\\` }
46
- s=${s// \" / \\\" }
47
- suggestions=$( for s in $sfcomplete ; do printf $' %q%q%q\n ' " $quote " " $s " " $quote " ; done)
52
+ suggestions=$( for s in $sfcomplete ; do
53
+ s=${s// \\ / \\\\ }
54
+ s=${s// \$ / \\\$ }
55
+ s=${s// \` / \\\` }
56
+ s=${s// \" / \\\" }
57
+ printf $' %q%q%q\n ' " $quote " " $s " " $quote " ;
58
+ done)
48
59
else
49
60
# no quotes: double escaping
50
61
suggestions=$( for s in $sfcomplete ; do printf $' %q\n ' $( printf ' %q' " $s " ) ; done)
You can’t perform that action at this time.
0 commit comments