Skip to content

Commit 5adf8e2

Browse files
committed
docs(CONTRIBUTING): discourage use of compgen -G pat
#1297 (comment)
1 parent db1d239 commit 5adf8e2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ Also, please bear the following coding guidelines in mind:
132132
expansions will be unexpectedly performed, which becomes a vulnerability. In
133133
the latter case, checks by shellcheck and shfmt will not be performed inside
134134
`'...'`. Also, `_comp_compgen_split` is `IFS`-safe.
135+
136+
Avoid using `_comp_compgen -- -G "pattern"` to generate completions. The
137+
result is not filtered by the current word `cur` due to the Bash design of
138+
`compgen`. Also, this cannot be used to generate filenames with a specified
139+
extension because the `-G` specification only generates the matching
140+
filepaths in the current directory. It does not look into subdirectories
141+
even when `$cur` implies the completion in a subdirectory. One can instead
142+
use `_comp_compgen -- -f -X '!pattern'`.
135143

136144
- When completing available options, offer only the most descriptive
137145
ones as completion results if there are multiple options that do the

0 commit comments

Comments
 (0)