bash_completion: Use default bash completion for files after `cros`.
The code originally use `compgen -o default` to generate a list of
completion after cros subcommands, which doesn't work well with
directories.
For example, the image is located at "./images/a.bin"
"cros flash imag<tab>" would complete to "cros flash images " currently,
and user have to delete the space, add '/' and press tab again for
completion.
Change it to return nothing, so it would fall back to "complete -o
bashdefault -o default" in this case, and the above case would complete
to "cros flash images/" as expected.
BUG=chromium:1029239
TEST=manually
Change-Id: I564a22a2457d146a7ffcf537432adca6806b8fd2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosutils/+/1941587
Tested-by: Pi-Hsun Shih <pihsun@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Craig Hesling <hesling@chromium.org>
diff --git a/bash_completion b/bash_completion
index b721699..b8a5d62 100644
--- a/bash_completion
+++ b/bash_completion
@@ -230,8 +230,7 @@
_complete_cros_command() {
local command="${COMP_WORDS[COMP_CWORD]}"
if [ ${COMP_CWORD} -ne 1 ]; then
- COMPREPLY=($(compgen -o default -- "${command}"))
- return 0
+ return 1
fi
local key="subcmds/cros"
@@ -279,7 +278,7 @@
complete -o bashdefault -o default -F _board_overlay setup_board
complete -o bashdefault -o default -o nospace -F _autotest_complete autotest
complete -o bashdefault -o default -o nospace -F _test_that_complete test_that
-complete -F _cros cros
+complete -o bashdefault -o default -F _cros cros
complete -F _cros_workon cros_workon
complete -o bashdefault -o default -F _complete_equery equery