File tree 1 file changed +5
-1
lines changed 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,10 @@ function _bash-it-component-completion-callback-on-init-aliases() {
78
78
# avoid recursive call loops by ignoring our own functions
79
79
if [[ " ${compl_func# _" $namespace " :: } " == " $compl_func " ]]; then
80
80
compl_wrapper=" _${namespace} ::${alias_name} "
81
+
82
+ # Create a wrapper function for the alias
83
+ # The use of printf on alias_arg_words is needed to ensure each element of
84
+ # the array is quoted. E.X. (one two three) -> ('one' 'two' 'three')
81
85
echo " function $compl_wrapper {
82
86
local compl_word=\$ {2?}
83
87
local prec_word=\$ {3?}
@@ -89,7 +93,7 @@ function _bash-it-component-completion-callback-on-init-aliases() {
89
93
prec_word=\$ {prec_word#* }
90
94
fi
91
95
(( COMP_CWORD += ${# alias_arg_words[@]} ))
92
- COMP_WORDS=(\" $alias_cmd \" \" ${alias_arg_words[*]} \" \"\$ {COMP_WORDS[@]:1}\" )
96
+ COMP_WORDS=(\" $alias_cmd \" $( printf " %q " " ${alias_arg_words[@]} " ) \"\$ {COMP_WORDS[@]:1}\" )
93
97
(( COMP_POINT -= \$ {#COMP_LINE} ))
94
98
COMP_LINE=\$ {COMP_LINE/$alias_name /$alias_cmd $alias_args }
95
99
(( COMP_POINT += \$ {#COMP_LINE} ))
You can’t perform that action at this time.
0 commit comments