[buildd-tools-devel] Bug#696543: [PATCH] etc: make bash completion work for colon values

Peter Wu lekensteyn at gmail.com
Sat Dec 22 15:48:59 UTC 2012


Package: schroot
Version: 1.6.4-1
Tags: patch

Patch is based on debian/schroot-1.6.3-1-33-g75634db, but should apply to any 
version (at least 1.3.2-1).

--chroot (and -c) accept values like chroot:foo and session:foo-abc. Standard
bash completion treats colons as whitespace, hence we need a way to force that
off.

Fix based on http://stackoverflow.com/q/10528695/427545 (thanks Radu Gasler!)
---
 etc/bash_completion/schroot | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/etc/bash_completion/schroot b/etc/bash_completion/schroot
index 035f0b3..7cda29b 100644
--- a/etc/bash_completion/schroot
+++ b/etc/bash_completion/schroot
@@ -21,14 +21,14 @@ _schroot()
     local cur prev options
 
     COMPREPLY=()
-    cur=${COMP_WORDS[COMP_CWORD]}
-    prev=${COMP_WORDS[COMP_CWORD-1]}
+    _get_comp_words_by_ref -n : cur prev
 
     # Select precisely the tokens from schroot --help that begin with a dash
     options=$(schroot --help | sed 's/\(^\|[[:space:]]\)[^[:space:]-]
[^[:space:]]*//g')
 
     if [ "$prev" = "-c" ] || [ "$prev" = "--chroot" ]; then
 	COMPREPLY=( $(compgen -W "$(schroot -a -l)" -- $cur) )
+	__ltrim_colon_completions "$cur"
     else
 	COMPREPLY=( $(compgen -W "$options" -- $cur) )
     fi
-- 
1.8.0.2



More information about the Buildd-tools-devel mailing list