[Bash-completion-commits] [SCM] bash-completion branch, master, updated. e96ef90c262e982b66b1d1bbe7a9bda7674a1f4e

Ville Skyttä ville.skytta at iki.fi
Fri May 22 13:29:23 UTC 2009


The following commit has been merged in the master branch:
commit e96ef90c262e982b66b1d1bbe7a9bda7674a1f4e
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Fri May 22 16:29:03 2009 +0300

    Use _split_longopt in samba completion, various option completion additions, fixes and improvements.

diff --git a/CHANGES b/CHANGES
index b886d26..130e02d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -39,7 +39,7 @@ bash-completion (1.x)
     take arguments in both "--foo bar" and "--foo=bar" formats.
   * Use _split_longopt to improve and clean up aspell, chgrp, chown, chkconfig,
     cpio, iptables, make, mc, mii-diag, mii-tool, mkinitrd, postgresql,
-    smartctl, and generic long option completion (Alioth: #311398).
+    samba, smartctl, and generic long option completion (Alioth: #311398).
   * Add chown --from and --reference value completions.
   * Add chgrp --reference value completion.
   * Do not assume all --foo= options take filenames in generic long option
@@ -50,6 +50,7 @@ bash-completion (1.x)
     tcpdump completions.
   * Split ant completion to contrib/ant, improve the built in one.
   * Improve postfix completion.
+  * Improve samba completion.
 
   [ Todd Zullinger ]
   * Make yum complete on filenames after install, deplist, update and upgrade
diff --git a/contrib/samba b/contrib/samba
index 0d524b9..714019a 100644
--- a/contrib/samba
+++ b/contrib/samba
@@ -25,14 +25,21 @@ _samba_hosts()
 	fi
 }
 
+_samba_debuglevel()
+{
+	COMPREPLY=( $( compgen -W '0 1 2 3 4 5 6 7 8 9 10' -- $cur ) )
+}
+
 _smbclient()
 {
-	local cur prev
+	local cur prev split=false
 
 	COMPREPLY=()
 	cur=`_get_cword`
 	prev=${COMP_WORDS[COMP_CWORD-1]}
 
+	_split_longopt && split=true
+
 	case $prev in
 		-R)
 			_samba_resolve_order
@@ -43,11 +50,11 @@ _smbclient()
 				HEX CAP' -- $cur ) )
 			return 0;
 			;;
-		-@(s|A))
+		-s|-A|--authentication-file)
 			_filedir
 			return 0;
 			;;
-		-l)
+		-l|--log-basename|-D)
 			_filedir -d
 			return 0;
 			;;
@@ -63,59 +70,61 @@ _smbclient()
 				$cur ) )
 			return 0;
 			;;
-		-W)
+		-W|--workgroup)
 			_samba_domains
 			return 0;
 			;;
+		-d|--debuglevel)
+			_samba_debuglevel
+			return 0
+			;;
+		-p|--port|-M|-I|-b|-U|--user|-n|-i|-T|-c)
+			# argument required but no completions available
+			return 0
+			;;
+		-\?|--help|-V|--version)
+			# all other arguments are noop with these
+			return 0
+			;;
 	esac
 
-	# --name=value style option
-	if [[ "$cur" == *=* ]]; then
-		prev=${cur/=*/}
-		cur=${cur/*=/}
-		case $prev in
-			--logfile)
-				_filedir -d
-				return 0;
-				;;
-			--authentication-file)
-				_filedir
-				return 0;
-				;;
-			--workgroup)
-				_samba_domains
-				return 0;
-				;;
-		esac
-	fi
+	$split && return 0
 
 	if [[ "$cur" == -* ]]; then
 		COMPREPLY=( $( compgen -W '-b -d -L -U -I -M -m -A -N -i -O \
-			-p -R -s -k -P -c -D -W -l -E --debuglevel= --logfile= \
-			--workgroup=' -- $cur ) )
+			-p -R -s -k -P -c -D -W -l -E --debuglevel \
+			--log-basename --workgroup' -- $cur ) )
 	fi
 }
 complete -F _smbclient smbclient
 
 _smbget()
 {
-	local cur prev
+	local cur prev split=false
 
 	COMPREPLY=()
 	cur=`_get_cword`
 	prev=${COMP_WORDS[COMP_CWORD-1]}
 
+	_split_longopt && split=true
+
 	case $prev in
 		-@(o|f|-outputfile|-rcfile))
 			_filedir
 			return 0;
 			;;
+		-d|--debuglevel)
+			_samba_debuglevel
+			return 0
+			;;
 	esac
 
+	$split && return 0
+
 	if [[ "$cur" == -* ]]; then
 		COMPREPLY=( $( compgen -W '-a --guest -r --resume -R \
-			--recursive -u --username= -p --password= -w \
-			--workgroup= -n --nonprompt -d --debuglevel= -D --dots \
+			--recursive -u --username -p --password -w \
+			--workgroup -n --nonprompt -d --debuglevel -D --dots \
 			-P --keep-permissions -o --outputfile -f --rcfile -q \
 			--quiet -v --verbose -b --blocksize -? --help --usage' \
 			-- $cur ) )
@@ -125,38 +134,34 @@ complete -F _smbget smbget
 
 _smbcacls()
 {
-	local cur prev
+	local cur prev split=false
 
 	COMPREPLY=()
 	cur=`_get_cword`
 	prev=${COMP_WORDS[COMP_CWORD-1]}
 
+	_split_longopt && split=true
+
 	case $prev in
 		-s)
 			_filedir
 			return 0;
 			;;
-		-l)
+		-l|--log-basename)
 			_filedir -d
 			return 0;
 			;;
+		-d|--debuglevel)
+			_samba_debuglevel
+			return 0
+			;;
 	esac
 
-	# --name=value style option
-	if [[ "$cur" == *=* ]]; then
-		prev=${cur/=*/}
-		cur=${cur/*=/}
-		case $prev in
-			--logfile)
-				_filedir -d
-				return 0;
-				;;
-		esac
-	fi
+	$split && return 0
 
 	if [[ "$cur" == -* ]]; then
 		COMPREPLY=( $( compgen -W '-a -M -D -S -U -C -G --numeric -t \
-			-h --help -V -s -d --debuglevel= -l --logfile=' -- \
+			-h --help -V -s -d --debuglevel -l --log-basename' -- \
 			$cur ) )
 	fi
 }
@@ -164,43 +169,35 @@ complete -F _smbcacls smbcacls
 
 _smbcquotas()
 {
-	local cur prev
+	local cur prev split=false
 
 	COMPREPLY=()
 	cur=`_get_cword`
 	prev=${COMP_WORDS[COMP_CWORD-1]}
 
+	_split_longopt && split=true
+
 	case $prev in
-		-@(s|A))
+		-s|-A|--authentication-file)
 			_filedir
 			return 0;
 			;;
-		-l)
+		-l|--log-basename)
 			_filedir -d
 			return 0;
 			;;
+		-d|--debuglevel)
+			_samba_debuglevel
+			return 0
+			;;
 	esac
 
-	# --name=value style option
-	if [[ "$cur" == *=* ]]; then
-		prev=${cur/=*/}
-		cur=${cur/*=/}
-		case $prev in
-			--logfile)
-				_filedir -d
-				return 0;
-				;;
-			--authentication-file)
-				_filedir
-				return 0;
-				;;
-		esac
-	fi
+	$split && return 0
 
 	if [[ "$cur" == -* ]]; then
 		COMPREPLY=( $( compgen -W '-u -L -F -S -n -t -v -h --help -V \
-			-s -d --debuglevel= -l --logfile= -N -k -A \
-			--authentication-file= -U --user=' -- $cur ) )
+			-s -d --debuglevel -l --log-basename -N -k -A \
+			--authentication-file -U --user' -- $cur ) )
 	fi
 }
 complete -F _smbcquotas smbcquotas
@@ -226,6 +223,10 @@ _smbpasswd()
 			_filedir
 			return 0;
 			;;
+		-D)
+			_samba_debuglevel
+			return 0
+			;;
 	esac
 
 	if [[ "$cur" == -* ]]; then
@@ -252,6 +253,10 @@ _smbtar()
 			_samba_hosts
 			return 0;
 			;;
+		-l)
+			_samba_debuglevel
+			return 0
+			;;
 	esac
 
 	if [[ "$cur" == -* ]]; then
@@ -263,42 +268,34 @@ complete -F _smbtar smbtar
 
 _smbtree()
 {
-	local cur prev
+	local cur prev split=false
 
 	COMPREPLY=()
 	cur=`_get_cword`
 	prev=${COMP_WORDS[COMP_CWORD-1]}
 
+	_split_longopt && split=true
+
 	case $prev in
-		-@(s|A))
+		-s|-A|--authentication-file)
 			_filedir
 			return 0;
 			;;
-		-l)
+		-l|--log-basename)
 			_filedir -d
 			return 0;
 			;;
+		-d|--debuglevel)
+			_samba_debuglevel
+			return 0
+			;;
 	esac
 
-	# --name=value style option
-	if [[ "$cur" == *=* ]]; then
-		prev=${cur/=*/}
-		cur=${cur/*=/}
-		case $prev in
-			--logfile)
-				_filedir -d
-				return 0;
-				;;
-			--authentication-file)
-				_filedir
-				return 0;
-				;;
-		esac
-	fi
+	$split && return 0
 
 	if [[ "$cur" == -* ]]; then
-		COMPREPLY=( $( compgen -W '-b -D -S -V -s -d --debuglevel= -l \
-			--logfile= -N -k -A --authentication-file= -U --user= \
+		COMPREPLY=( $( compgen -W '-b -D -S -V -s -d --debuglevel -l \
+			--log-basename -N -k -A --authentication-file -U --user\
 			-h --help' -- $cur ) )
 	fi
 }

-- 
bash-completion



More information about the Bash-completion-commits mailing list