@@ -117,15 +117,21 @@ Also, please bear the following coding guidelines in mind:
117
117
variables are set (e.g. with ` [[ -v varname ]] ` ) or use default
118
118
expansion (e.g. ` ${varname-} ` ).
119
119
120
- - Prefer ` compgen -W '...' -- $cur ` over embedding ` $cur ` in external
121
- command arguments (often e.g. sed, grep etc) unless there's a good
122
- reason to embed it. Embedding user input in command lines can result
123
- in syntax errors and other undesired behavior, or messy quoting
124
- requirements when the input contains unusual characters. Good
125
- reasons for embedding include functionality (if the thing does not
126
- sanely work otherwise) or performance (if it makes a big difference
127
- in speed), but all embedding cases should be documented with
128
- rationale in comments in the code.
120
+ - Prefer ` _comp_compgen_split -- "$(...)" ` over embedding ` $cur ` in external
121
+ command arguments (often e.g. sed, grep etc) unless there's a good reason to
122
+ embed it. Embedding user input in command lines can result in syntax errors
123
+ and other undesired behavior, or messy quoting requirements when the input
124
+ contains unusual characters. Good reasons for embedding include
125
+ functionality (if the thing does not sanely work otherwise) or performance
126
+ (if it makes a big difference in speed), but all embedding cases should be
127
+ documented with rationale in comments in the code.
128
+
129
+ Do not use ` _comp_compgen -- -W "$(...)" ` or ` _comp_compgen -- -W '$(...)' `
130
+ but always use ` _comp_compgen_split -- "$(...)" ` . In the former case, when
131
+ the command output contains strings looking like shell expansions, the
132
+ expansions will be unexpectedly performed, which becomes a vulnerability. In
133
+ the latter case, checks by shellcheck and shfmt will not be performed inside
134
+ ` '...' ` . Also, ` _comp_compgen_split ` is ` IFS ` -safe.
129
135
130
136
- When completing available options, offer only the most descriptive
131
137
ones as completion results if there are multiple options that do the
0 commit comments