Properly handle spaces in filenames in bash autocomplete (#9702)

pull/9708/head
wr7 9 months ago committed by GitHub
parent b7b6f30084
commit 7100ed4efc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -5,19 +5,20 @@ _hx() {
# $1 command name # $1 command name
# $2 word being completed # $2 word being completed
# $3 word preceding # $3 word preceding
COMPREPLY=()
case "$3" in case "$3" in
-g | --grammar) -g | --grammar)
COMPREPLY=($(compgen -W "fetch build" -- $2)) COMPREPLY="$(compgen -W "fetch build" -- $2)"
;; ;;
--health) --health)
local languages=$(hx --health |tail -n '+7' |awk '{print $1}' |sed 's/\x1b\[[0-9;]*m//g') local languages=$(hx --health |tail -n '+7' |awk '{print $1}' |sed 's/\x1b\[[0-9;]*m//g')
COMPREPLY=($(compgen -W "$languages" -- $2)) COMPREPLY="$(compgen -W "$languages" -- $2)"
;; ;;
*) *)
COMPREPLY=($(compgen -fd -W "-h --help --tutor -V --version -v -vv -vvv --health -g --grammar --vsplit --hsplit -c --config --log" -- $2)) COMPREPLY="$(compgen -fd -W "-h --help --tutor -V --version -v -vv -vvv --health -g --grammar --vsplit --hsplit -c --config --log" -- $2)"
;; ;;
esac esac
} && complete -o filenames -F _hx hx
local IFS=$'\n'
COMPREPLY=($COMPREPLY)
} && complete -o filenames -F _hx hx

Loading…
Cancel
Save