Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit56a74ed

Browse files
committed
Use single-quotes by default to complete fqcn and fix empty input in completion
1 parentcb027ea commit56a74ed

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

‎src/Symfony/Component/Console/Resources/completion.bash‎

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,43 @@ _sf_{{ COMMAND_NAME }}() {
1919
local completecmd=("$sf_cmd""_complete""-sbash""-c$cword""-S{{ VERSION }}")
2020
forwin${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 sin$sfcomplete;doprintf$'%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 sin$sfcomplete;doprintf$'%q%q%q\n'"$quote""$s""$quote"; done)
52+
suggestions=$(for sin$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 sin$sfcomplete;doprintf$'%q\n'$(printf'%q'"$s"); done)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp