File tree Expand file tree Collapse file tree 1 file changed +22
-11
lines changed
src/Symfony/Component/Console/Resources Expand file tree Collapse file tree 1 file changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -19,32 +19,43 @@ _sf_{{ COMMAND_NAME }}() {
1919 local completecmd=(" $sf_cmd " " _complete" " -sbash" " -c$cword " " -S{{ VERSION }}" )
2020 for w in ${words[@]} ; do
2121 w=$( printf -- ' %b' " $w " )
22- # remove quotes
22+ # remove quotes from typed values
2323 quote=" ${w: 0: 1} "
24- if [ " $quote " == " ' " ]; then
24+ if [ " $quote " == \' ]; then
2525 w=" ${w% \' } "
2626 w=" ${w# \' } "
27- elif [ " $quote " == ' " ' ]; then
27+ elif [ " $quote " == \" ]; then
2828 w=" ${w% \" } "
2929 w=" ${w# \" } "
3030 fi
31- completecmd+=(" -i$w " )
31+ # empty values are ignored
32+ if [ ! -z " $w " ]; then
33+ completecmd+=(" -i$w " )
34+ fi
3235 done
3336
3437 local sfcomplete
3538 if sfcomplete=$( ${completecmd[@]} 2>&1 ) ; then
3639 local quote suggestions
3740 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
3948 # single quotes: no additional escaping (does not accept ' in values)
4049 suggestions=$( for s in $sfcomplete ; do printf $' %q%q%q\n ' " $quote " " $s " " $quote " ; done)
41- elif [ " $quote " == ' " ' ]; then
50+ elif [ " $quote " == \" ]; then
4251 # 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)
4859 else
4960 # no quotes: double escaping
5061 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