Merge pull request #8337 from pmarques/master

Fix vagrant bash completion when path have spaces
This commit is contained in:
Chris Roberts 2017-03-08 06:10:00 -08:00 committed by GitHub
commit 258a58bcae
1 changed files with 9 additions and 9 deletions

View File

@ -71,9 +71,9 @@ _vagrant() {
;;
"up")
vagrant_state_file=$(__vagrantinvestigate) || return 1
if [[ -d $vagrant_state_file ]]
if [[ -d "${vagrant_state_file}" ]]
then
local vm_list=$(find $vagrant_state_file/machines -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
local vm_list=$(find "${vagrant_state_file}/machines" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
fi
local up_commands="--no-provision"
COMPREPLY=($(compgen -W "${up_commands} ${vm_list}" -- ${cur}))
@ -81,12 +81,12 @@ _vagrant() {
;;
"ssh"|"provision"|"reload"|"halt"|"suspend"|"resume"|"ssh-config")
vagrant_state_file=$(__vagrantinvestigate) || return 1
if [[ -f $vagrant_state_file ]]
if [[ -f "${vagrant_state_file}" ]]
then
running_vm_list=$(grep 'active' $vagrant_state_file | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ')
else
running_vm_list=$(find $vagrant_state_file -type f -name "id" | awk -F"/" '{print $(NF-2)}')
fi
running_vm_list=$(grep 'active' "${vagrant_state_file}" | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ')
else
running_vm_list=$(find "${vagrant_state_file}" -type f -name "id" | awk -F"/" '{print $(NF-2)}')
fi
COMPREPLY=($(compgen -W "${running_vm_list}" -- ${cur}))
return 0
;;
@ -121,9 +121,9 @@ _vagrant() {
"up")
if [ "$prev" == "--no-provision" ]
then
if [[ -d $vagrant_state_file ]]
if [[ -d "${vagrant_state_file}" ]]
then
local vm_list=$(find $vagrant_state_file/machines -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
local vm_list=$(find "${vagrant_state_file}/machines" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
fi
COMPREPLY=($(compgen -W "${vm_list}" -- ${cur}))
return 0