Fix vagrant bash completion when path have spaces
This commit is contained in:
parent
363476fbae
commit
68d019926f
|
@ -71,9 +71,9 @@ _vagrant() {
|
||||||
;;
|
;;
|
||||||
"up")
|
"up")
|
||||||
vagrant_state_file=$(__vagrantinvestigate) || return 1
|
vagrant_state_file=$(__vagrantinvestigate) || return 1
|
||||||
if [[ -d $vagrant_state_file ]]
|
if [[ -d "${vagrant_state_file}" ]]
|
||||||
then
|
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
|
fi
|
||||||
local up_commands="--no-provision"
|
local up_commands="--no-provision"
|
||||||
COMPREPLY=($(compgen -W "${up_commands} ${vm_list}" -- ${cur}))
|
COMPREPLY=($(compgen -W "${up_commands} ${vm_list}" -- ${cur}))
|
||||||
|
@ -81,12 +81,12 @@ _vagrant() {
|
||||||
;;
|
;;
|
||||||
"ssh"|"provision"|"reload"|"halt"|"suspend"|"resume"|"ssh-config")
|
"ssh"|"provision"|"reload"|"halt"|"suspend"|"resume"|"ssh-config")
|
||||||
vagrant_state_file=$(__vagrantinvestigate) || return 1
|
vagrant_state_file=$(__vagrantinvestigate) || return 1
|
||||||
if [[ -f $vagrant_state_file ]]
|
if [[ -f "${vagrant_state_file}" ]]
|
||||||
then
|
then
|
||||||
running_vm_list=$(grep 'active' $vagrant_state_file | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ')
|
running_vm_list=$(grep 'active' "${vagrant_state_file}" | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ')
|
||||||
else
|
else
|
||||||
running_vm_list=$(find $vagrant_state_file -type f -name "id" | awk -F"/" '{print $(NF-2)}')
|
running_vm_list=$(find "${vagrant_state_file}" -type f -name "id" | awk -F"/" '{print $(NF-2)}')
|
||||||
fi
|
fi
|
||||||
COMPREPLY=($(compgen -W "${running_vm_list}" -- ${cur}))
|
COMPREPLY=($(compgen -W "${running_vm_list}" -- ${cur}))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
|
@ -121,9 +121,9 @@ _vagrant() {
|
||||||
"up")
|
"up")
|
||||||
if [ "$prev" == "--no-provision" ]
|
if [ "$prev" == "--no-provision" ]
|
||||||
then
|
then
|
||||||
if [[ -d $vagrant_state_file ]]
|
if [[ -d "${vagrant_state_file}" ]]
|
||||||
then
|
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
|
fi
|
||||||
COMPREPLY=($(compgen -W "${vm_list}" -- ${cur}))
|
COMPREPLY=($(compgen -W "${vm_list}" -- ${cur}))
|
||||||
return 0
|
return 0
|
||||||
|
|
Loading…
Reference in New Issue