Skip to content

Commit 5882b4f

Browse files
committed
bug symfony#48179 [Console] Support completion for bash functions (Chi-teck)
This PR was submitted for the 6.2 branch but it was merged into the 5.4 branch instead. Discussion ---------- [Console] Support completion for bash functions | Q | A | ------------- | --- | Branch | 6.2 | Bug fix? | no | New feature | yes | Deprecations | no | License | MIT I often use bash functions as wrappers for executable files that live in vendor/bin. So that they can be executed from any location within a project. Symfony Console has recently added support for Bash completions but right now that only applies to executable files and aliases. This PR adds support for Bash functions. Commits ------- 1321278 Support completion for bash functions
2 parents d4fab7f + 1321278 commit 5882b4f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ _sf_{{ COMMAND_NAME }}() {
1111
local sf_cmd="${COMP_WORDS[0]}"
1212

1313
# for an alias, get the real script behind it
14-
if [[ $(type -t $sf_cmd) == "alias" ]]; then
14+
sf_cmd_type=$(type -t $sf_cmd)
15+
if [[ $sf_cmd_type == "alias" ]]; then
1516
sf_cmd=$(alias $sf_cmd | sed -E "s/alias $sf_cmd='(.*)'/\1/")
16-
else
17+
elif [[ $sf_cmd_type == "file" ]]; then
1718
sf_cmd=$(type -p $sf_cmd)
1819
fi
1920

20-
if [ ! -x "$sf_cmd" ]; then
21+
if [[ $sf_cmd_type != "function" && ! -x $sf_cmd ]]; then
2122
return 1
2223
fi
2324

0 commit comments

Comments
 (0)