1
1
# bash completion for smartctl(8) -*- shell-script -*-
2
+ # Updated for smartmontools 7.5 (released 2025-04-30)
2
3
3
4
_comp_cmd_smartctl__device ()
4
5
{
5
6
case $cur in
6
- areca * | 3ware * | megaraid * | cciss * )
7
+ 3ware, * | cciss, * | areca, * | megaraid, * )
7
8
_comp_compgen -- -W ' ${cur%%,*},{0..31}'
8
9
;;
9
- hpt* )
10
+ aacraid,* )
11
+ _comp_compgen -- -W ' aacraid,{0..1},{0..1},{0..7}'
12
+ ;;
13
+ hpt,* )
10
14
_comp_compgen -- -W ' hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5}'
11
15
;;
16
+ sssraid,* )
17
+ _comp_compgen -- -W ' sssraid,{0..1},{0..31}'
18
+ ;;
19
+ jmb39x,* | jmb39x-q,* | jmb39x-q2,* | jms56x,* )
20
+ _comp_compgen -- -W ' ${cur%%,*},{0..4}'
21
+ ;;
12
22
* )
13
- _comp_compgen -- -W ' ata scsi sat usbcypress usbjmicron usbsunplus
14
- marvell areca 3ware hpt megaraid cciss auto test'
15
- case " ${COMPREPLY[@]} " in
16
- areca | 3ware | hpt | megaraid | cciss)
17
- compopt -o nospace
18
- ;;
19
- esac
23
+ _comp_compgen -- -W ' auto test ata scsi nvme{,\,}
24
+ sat{,\,auto}{,\,12} usb{jmicron,prolific,sunplus}
25
+ snt{asmedia,jmicron,realtek}{,/sat} 3ware, aacraid, areca,
26
+ cciss, hpt, megaraid, sssraid, jmb39x{,-q,-q2}, jms56x,'
27
+ [[ ${COMPREPLY-} == * , ]] && compopt -o nospace
20
28
;;
21
29
esac
22
30
}
23
- _comp_cmd_smartctl__test ()
24
- {
25
- [[ $cur == @ (pending| scttempint| vendor), ]] && return
26
- _comp_compgen -- -W ' offline short long conveyance select, select,redo
27
- select,next afterselect,on afterselect,off pending, scttempint,
28
- vendor,'
29
- [[ ${COMPREPLY-} == * , ]] && compopt -o nospace
30
- }
31
31
_comp_cmd_smartctl__drivedb ()
32
32
{
33
33
local prefix=
@@ -38,13 +38,42 @@ _comp_cmd_smartctl__drivedb()
38
38
_comp_compgen_filedir h && [[ $prefix ]] &&
39
39
_comp_compgen -Rv COMPREPLY -- -P " $prefix " -W ' "${COMPREPLY[@]}"'
40
40
}
41
+ _comp_cmd_smartctl__vendorattribute ()
42
+ {
43
+ local fmt
44
+ case $cur in
45
+ [1-9N],* |[1-9][0-9],* |1[0-9][0-9],* |2[0-4][0-9],* |25[0-5],* )
46
+ fmt=' raw{8,16,48,56,64},hex{48,56,64},raw24/raw{24,32}'
47
+ fmt+=' ,msec24hour32,{sec,min,halfmin}2hour,temp10x,tempminmax'
48
+ _comp_compgen -- -W ' ${cur%%,*},{' " $fmt " ' }{,\,,}'
49
+ ;;
50
+ [1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])
51
+ _comp_compgen -- -W ' ${cur}, {100..255},'
52
+ ;;
53
+ [1-9])
54
+ _comp_compgen -- -W ' ${cur}, ${cur}{0..9}'
55
+ ;;
56
+ * )
57
+ _comp_compgen -- -W ' {1..9} N, help'
58
+ ;;
59
+ esac
60
+ [[ ${COMPREPLY-} == * , ]] && compopt -o nospace
61
+ }
62
+ _comp_cmd_smartctl__set ()
63
+ {
64
+ _comp_compgen -- -W ' aam,{,off} apm,{,off} dsn,{on,off}
65
+ lookahead,{on,off} rcache,{on,off} security-freeze standby,{,off,now}
66
+ wcache,{on,off} wcache-sct,{ata,on,off}{,\,p}
67
+ wcreorder,{on,off}{,\,p} ' " $1 "
68
+ [[ ${COMPREPLY-} == * , ]] && compopt -o nospace
69
+ }
41
70
42
71
_comp_cmd_smartctl ()
43
72
{
44
73
local cur prev words cword was_split comp_args
45
74
_comp_initialize -s -- " $@ " || return
46
75
47
- local noargopts=' !(-*|*[qdTbrnsoSlvFPBt ]*)'
76
+ local noargopts=' !(-*|*[qdTbrnoSlvFPBtfgs ]*)'
48
77
# shellcheck disable=SC2254
49
78
case $prev in
50
79
--quietmode | -${noargopts} q)
@@ -64,32 +93,34 @@ _comp_cmd_smartctl()
64
93
return
65
94
;;
66
95
--report | -${noargopts} r)
67
- _comp_compgen -- -W ' ioctl ataioctl scsiioctl '
96
+ _comp_compgen -- -W ' {,ata,scsi,nvme} ioctl{,\,2} '
68
97
return
69
98
;;
70
99
--nocheck | -${noargopts} n)
71
- _comp_compgen -- -W ' never sleep standby idle'
100
+ _comp_compgen -- -W ' never sleep{,\,} standby{,\,} idle{,\,}'
101
+ [[ ${COMPREPLY-} == * , ]] && compopt -o nospace
72
102
return
73
103
;;
74
- --smart | --offlineauto | --saveauto | -${noargopts} [soS ])
104
+ --smart | --offlineauto | --saveauto | -${noargopts} [oS ])
75
105
_comp_compgen -- -W ' on off'
76
106
return
77
107
;;
78
108
--log | -${noargopts} l)
79
- _comp_compgen -- -W ' error selftest selective directory background
80
- sasphy sasphy,reset sataphy sataphy,reset scttemp scttempsts
81
- scttemphist scterc gplog smartlog xerror xselftest'
109
+ _comp_compgen -- -W ' background defects{,\,} devstat{,\,}
110
+ directory{,\,g,\,s} envrep error farm genstats gplog, nvmelog,
111
+ sasphy{,\,reset} sataphy{,\,reset} scterc{,\,,\,p,\,reset}
112
+ scttemp{,sts,int\,,hist} selective selftest smartlog, ssd
113
+ tapealert tapedevstat xerror{,\,,\,error}
114
+ xselftest{,\,,\,selftest} zdevstat'
115
+ [[ ${COMPREPLY-} == * , ]] && compopt -o nospace
82
116
return
83
117
;;
84
118
--vendorattribute | -${noargopts} v)
85
- _comp_compgen -- -W ' help 9,minutes 9,seconds 9,halfminutes 9,temp
86
- 192,emergencyretractcyclect 193,loadunload 194,10xCelsius
87
- 194,unknown 198,offlinescanuncsectorct 200,writeerrorcount
88
- 201,detectedtacount 220,temp'
119
+ _comp_cmd_smartctl__vendorattribute
89
120
return
90
121
;;
91
122
--firmwarebug | -${noargopts} F)
92
- _comp_compgen -- -W ' none samsung samsung2 samsung3 swapid'
123
+ _comp_compgen -- -W ' none nologdir samsung{,2,3} swapid xerrorlba '
93
124
return
94
125
;;
95
126
--presets | -${noargopts} P)
@@ -101,15 +132,41 @@ _comp_cmd_smartctl()
101
132
return
102
133
;;
103
134
--test | -${noargopts} t)
104
- _comp_cmd_smartctl__test
135
+ _comp_compgen -- -W ' afterselect,{on,off} conveyance force long
136
+ offline pending, scttempint, select,{,redo,next} short vendor,'
137
+ [[ ${COMPREPLY-} == * , ]] && compopt -o nospace
138
+ return
139
+ ;;
140
+ --format | -${noargopts} f)
141
+ _comp_compgen -- -W ' brief hex{,\,id,\,val} old'
142
+ return
143
+ ;;
144
+ --get | -${noargopts} g)
145
+ _comp_compgen -- -W ' aam all apm dsn lookahead rcache security
146
+ wcache{,-sct} wcreorder'
147
+ return
148
+ ;;
149
+ --set)
150
+ _comp_cmd_smartctl__set ' '
151
+ return
152
+ ;;
153
+ -${noargopts} s) # -s {on,off}: --smart {on,off}; -s OTHER: --set OTHER
154
+ _comp_cmd_smartctl__set ' on off'
105
155
return
106
156
;;
107
157
esac
108
158
109
159
[[ $was_split ]] && return
110
160
111
161
if [[ $cur == -* ]]; then
112
- _comp_compgen_help
162
+ # _comp_compgen_help # not used because result is incomplete
163
+ _comp_compgen -- -W ' --abort --all --attributes --badsum=
164
+ --capabilities --captive --device= --drivedb= --firmwarebug=
165
+ --format= --get= --health --help --identify{,=} --info --json{,=}
166
+ --log= --nocheck= --offlineauto= --presets= --quietmode= --report=
167
+ --saveauto= --scan{,-open} --set= --smart= --test= --tolerance=
168
+ --vendorattribute= --version --xall -A -B -C -F -H -P -S -T -V -X
169
+ -a -b -c -d -f -g -h -i -j -l -n -o -q -r -s -t -v -x'
113
170
[[ ${COMPREPLY-} == * = ]] && compopt -o nospace
114
171
else
115
172
_comp_compgen -c " ${cur:-/ dev/ } " filedir
0 commit comments