[Bash-completion-commits] ./current r1307: initial import

Guillaume Rousse guillomovitch at zarb.org
Wed Feb 4 20:23:49 UTC 2009


------------------------------------------------------------
revno: 1307
committer: Guillaume Rousse <guillomovitch at zarb.org>
branch nick: current
timestamp: Wed 2009-02-04 21:23:49 +0100
message:
  initial import
added:
  to_review/smartmontools
-------------- next part --------------
=== added file 'to_review/smartmontools'
--- a/to_review/smartmontools	1970-01-01 00:00:00 +0000
+++ b/to_review/smartmontools	2009-02-04 20:23:49 +0000
@@ -0,0 +1,195 @@
+# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
+# ex: ts=8 sw=8 noet filetype=sh
+#
+# bash completion for smartctl
+
+have smartctl && {
+_smartctl_quietmode()
+{
+	COMPREPLY=( $( compgen -W 'errorsonly silent' -- $cur ) )
+}
+_smartctl_device()
+{
+	COMPREPLY=( $( compgen -W 'ata scsi 3ware' -- $cur ) )
+}
+_smartctl_tolerance()
+{
+	COMPREPLY=( $( compgen -W 'warn exit ignore' -- $cur ) )
+}
+_smartctl_badsum()
+{
+	COMPREPLY=( $( compgen -W 'normal conservative permissive verypermissive' -- $cur ) )
+}
+_smartctl_report()
+{
+	COMPREPLY=( $( compgen -W 'ioctl ataioctl scsiioctl' -- $cur ) )
+}
+_smartctl_feature()
+{
+	COMPREPLY=( $( compgen -W 'on off' -- $cur ) )
+}
+_smartctl_log()
+{
+	COMPREPLY=( $( compgen -W 'error selftest selective directory' -- $cur ) )
+}
+_smartctl_vendorattribute()
+{
+	COMPREPLY=( $( compgen -W 'help 9,minutes 9,seconds 9,halfminutes \
+		9,temp 192,emergencyretractcyclect 193,loadunload \
+		194,10xCelsius 194,unknown 198,offlinescanuncsectorct \
+		200,writeerrorcount 201,detectedtacount 220,temp' -- $cur ) )
+}
+_smartctl_firmwarebug()
+{
+	COMPREPLY=( $( compgen -W 'none samsung samsung2' -- $cur ) )
+}
+_smartctl_presets()
+{
+	COMPREPLY=( $( compgen -W 'use ignore show showall' -- $cur ) )
+}
+_smartctl_test()
+{
+	COMPREPLY=( $( compgen -W 'offline short long conveyance select afterselect,on afterselect,off pending' -- $cur ) )
+}
+
+
+_smartctl()
+{
+	local cur prev
+
+	COMPREPLY=()
+	cur=${COMP_WORDS[COMP_CWORD]}
+	prev=${COMP_WORDS[COMP_CWORD-1]}
+
+	# --name value style option
+	case "$prev" in
+		-q)
+			_smartctl_quietmode
+			;;
+		-d)
+			_smartctl_device
+			return 0
+			;;
+		-t)
+			_smartctl_tolerance
+			return 0
+			;;
+		-b)
+			_smartctl_badsum
+			return 0
+			;;
+		-r)
+			_smartctl_report
+			return 0
+			;;
+		-s)
+			_smartctl_feature
+			return 0
+			;;
+		-o)
+			_smartctl_feature
+			return 0
+			;;
+		-S)
+			_smartctl_feature
+			return 0
+			;;
+		-l)
+			_smartctl_log
+			return 0
+			;;
+		-v)
+			_smartctl_vendorattribute
+			return 0
+			;;
+		-F)
+			_smartctl_firmwarebug
+			return 0
+			;;
+		-P)
+			_smartctl_presets
+			return 0
+			;;
+		-t)
+			_smartctl_test
+			return 0
+			;;
+	esac
+
+	# --name=value style option
+	if [[ "$cur" == *=* ]]; then
+		prev=${cur/=*/}
+		cur=${cur/*=/}
+		case "$prev" in
+			--quietmode)
+				_smartctl_quietmode
+				return 0
+				;;
+			--device)
+				_smartctl_device
+				return 0
+				;;
+			--tolerance)
+				_smartctl_tolerance
+				return 0
+				;;
+			--badsum)
+				_smartctl_badsum
+				return 0
+				;;
+			--report)
+				_smartctl_report
+				return 0
+				;;
+			--smart)
+				_smartctl_feature
+				return 0
+				;;
+			--offlineauto)
+				_smartctl_feature
+				return 0
+				;;
+			--saveauto)
+				_smartctl_feature
+				return 0
+				;;
+			--log)
+				_smartctl_log
+				return 0
+				;;
+			--vendorattribute)
+				_smartctl_vendorattribute
+				return 0
+				;;
+			--firmwarebug)
+				_smartctl_firmwarebug
+				return 0
+				;;
+			--presets)
+				_smartctl_presets
+				return 0
+				;;
+			--test)
+				_smartctl_test
+				return 0
+				;;
+		esac
+	fi
+
+
+	if [[ "$cur" == -* ]]; then
+		COMPREPLY=( $( compgen -W '-h --help --usage -V --version \
+			--copyright --license-i --info -a --all -q \
+			--quietmode= -d --device= -T --tolerance= -b --badsum= \
+			-r --report= -s --smart= -o --offlineauto= -S \
+			--saveauto= -H --health -c --capabilities -A \
+			--attributes -l --log= -v --vendorattribute= -F \
+			--firmwarebug= -P --presets= -t --test= -C \
+			--captive -X --abort' -- $cur ) )
+	else
+		cur=${cur:=/dev/}
+		_filedir
+	fi
+}
+complete -F _smartctl smartctl
+}



More information about the Bash-completion-commits mailing list