diff --git a/src/completions/bash.rs b/src/completions/bash.rs index 664b52ef724..37dfa66983f 100644 --- a/src/completions/bash.rs +++ b/src/completions/bash.rs @@ -44,7 +44,7 @@ impl<'a, 'b> BashGen<'a, 'b> { {name}) opts="{name_opts}" if [[ ${{cur}} == -* || ${{COMP_CWORD}} -eq 1 ]] ; then - COMPREPLY=( $(compgen -W "${{opts}}" -- ${{cur}}) ) + COMPREPLY=( $(compgen -W "${{opts}}" -- "${{cur}}") ) return 0 fi case "${{prev}}" in @@ -53,7 +53,7 @@ impl<'a, 'b> BashGen<'a, 'b> { COMPREPLY=() ;; esac - COMPREPLY=( $(compgen -W "${{opts}}" -- ${{cur}}) ) + COMPREPLY=( $(compgen -W "${{opts}}" -- "${{cur}}") ) return 0 ;; {subcmd_details} @@ -105,7 +105,7 @@ complete -F _{name} -o bashdefault -o default {name} {subcmd}) opts="{sc_opts}" if [[ ${{cur}} == -* || ${{COMP_CWORD}} -eq {level} ]] ; then - COMPREPLY=( $(compgen -W "${{opts}}" -- ${{cur}}) ) + COMPREPLY=( $(compgen -W "${{opts}}" -- "${{cur}}") ) return 0 fi case "${{prev}}" in @@ -114,7 +114,7 @@ complete -F _{name} -o bashdefault -o default {name} COMPREPLY=() ;; esac - COMPREPLY=( $(compgen -W "${{opts}}" -- ${{cur}}) ) + COMPREPLY=( $(compgen -W "${{opts}}" -- "${{cur}}") ) return 0 ;;"#, subcmd_dets, @@ -169,9 +169,9 @@ complete -F _{name} -o bashdefault -o default {name} debugln!("BashGen::vals_for: o={}", o.b.name); use args::AnyArg; if let Some(vals) = o.possible_vals() { - format!(r#"$(compgen -W "{}" -- ${{cur}})"#, vals.join(" ")) + format!(r#"$(compgen -W "{}" -- "${{cur}}")"#, vals.join(" ")) } else { - String::from("$(compgen -f ${cur})") + String::from(r#"$(compgen -f "${cur}")"#) } } diff --git a/tests/completions.rs b/tests/completions.rs index 34566d3e012..24409ade044 100644 --- a/tests/completions.rs +++ b/tests/completions.rs @@ -34,7 +34,7 @@ static BASH: &'static str = r#"_myapp() { myapp) opts=" -h -V --help --version test help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi case "${prev}" in @@ -43,14 +43,14 @@ static BASH: &'static str = r#"_myapp() { COMPREPLY=() ;; esac - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; myapp__help) opts=" -h -V --help --version " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi case "${prev}" in @@ -59,26 +59,26 @@ static BASH: &'static str = r#"_myapp() { COMPREPLY=() ;; esac - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; myapp__test) opts=" -h -V --help --version --case " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi case "${prev}" in --case) - COMPREPLY=($(compgen -f ${cur})) + COMPREPLY=($(compgen -f "${cur}")) return 0 ;; *) COMPREPLY=() ;; esac - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; esac @@ -561,7 +561,7 @@ static BASH_SPECIAL_CMDS: &'static str = r#"_my_app() { my_app) opts=" -h -V --help --version test some_cmd some-cmd-with-hypens help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi case "${prev}" in @@ -570,14 +570,14 @@ static BASH_SPECIAL_CMDS: &'static str = r#"_my_app() { COMPREPLY=() ;; esac - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; my_app__help) opts=" -h -V --help --version " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi case "${prev}" in @@ -586,13 +586,13 @@ static BASH_SPECIAL_CMDS: &'static str = r#"_my_app() { COMPREPLY=() ;; esac - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; my_app__some__cmd__with__hypens) opts=" -h -V --help --version " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi case "${prev}" in @@ -601,45 +601,45 @@ static BASH_SPECIAL_CMDS: &'static str = r#"_my_app() { COMPREPLY=() ;; esac - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; my_app__some_cmd) opts=" -h -V --help --version --config " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi case "${prev}" in --config) - COMPREPLY=($(compgen -f ${cur})) + COMPREPLY=($(compgen -f "${cur}")) return 0 ;; *) COMPREPLY=() ;; esac - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; my_app__test) opts=" -h -V --help --version --case " if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi case "${prev}" in --case) - COMPREPLY=($(compgen -f ${cur})) + COMPREPLY=($(compgen -f "${cur}")) return 0 ;; *) COMPREPLY=() ;; esac - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; esac