Skip to content

Commit 4396104

Browse files
committed
feat(smartctl): update for smartmontools 7.5
1 parent c55ee7f commit 4396104

File tree

1 file changed

+88
-31
lines changed

1 file changed

+88
-31
lines changed

completions/smartctl

Lines changed: 88 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
# bash completion for smartctl(8) -*- shell-script -*-
2+
# Updated for smartmontools 7.5 (released 2025-04-30)
23

34
_comp_cmd_smartctl__device()
45
{
56
case $cur in
6-
areca* | 3ware* | megaraid* | cciss*)
7+
3ware,* | cciss,* | areca,* | megaraid,*)
78
_comp_compgen -- -W '${cur%%,*},{0..31}'
89
;;
9-
hpt*)
10+
aacraid,*)
11+
_comp_compgen -- -W 'aacraid,{0..1},{0..1},{0..7}'
12+
;;
13+
hpt,*)
1014
_comp_compgen -- -W 'hpt,{1..4}/{1..8} hpt,{1..4}/{1..8}/{1..5}'
1115
;;
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+
;;
1222
*)
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
2028
;;
2129
esac
2230
}
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-
}
3131
_comp_cmd_smartctl__drivedb()
3232
{
3333
local prefix=
@@ -38,13 +38,42 @@ _comp_cmd_smartctl__drivedb()
3838
_comp_compgen_filedir h && [[ $prefix ]] &&
3939
_comp_compgen -Rv COMPREPLY -- -P "$prefix" -W '"${COMPREPLY[@]}"'
4040
}
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+
}
4170

4271
_comp_cmd_smartctl()
4372
{
4473
local cur prev words cword was_split comp_args
4574
_comp_initialize -s -- "$@" || return
4675

47-
local noargopts='!(-*|*[qdTbrnsoSlvFPBt]*)'
76+
local noargopts='!(-*|*[qdTbrnoSlvFPBtfgs]*)'
4877
# shellcheck disable=SC2254
4978
case $prev in
5079
--quietmode | -${noargopts}q)
@@ -64,32 +93,34 @@ _comp_cmd_smartctl()
6493
return
6594
;;
6695
--report | -${noargopts}r)
67-
_comp_compgen -- -W 'ioctl ataioctl scsiioctl'
96+
_comp_compgen -- -W '{,ata,scsi,nvme}ioctl{,\,2}'
6897
return
6998
;;
7099
--nocheck | -${noargopts}n)
71-
_comp_compgen -- -W 'never sleep standby idle'
100+
_comp_compgen -- -W 'never sleep{,\,} standby{,\,} idle{,\,}'
101+
[[ ${COMPREPLY-} == *, ]] && compopt -o nospace
72102
return
73103
;;
74-
--smart | --offlineauto | --saveauto | -${noargopts}[soS])
104+
--smart | --offlineauto | --saveauto | -${noargopts}[oS])
75105
_comp_compgen -- -W 'on off'
76106
return
77107
;;
78108
--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
82116
return
83117
;;
84118
--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
89120
return
90121
;;
91122
--firmwarebug | -${noargopts}F)
92-
_comp_compgen -- -W 'none samsung samsung2 samsung3 swapid'
123+
_comp_compgen -- -W 'none nologdir samsung{,2,3} swapid xerrorlba'
93124
return
94125
;;
95126
--presets | -${noargopts}P)
@@ -101,15 +132,41 @@ _comp_cmd_smartctl()
101132
return
102133
;;
103134
--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'
105155
return
106156
;;
107157
esac
108158

109159
[[ $was_split ]] && return
110160

111161
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'
113170
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
114171
else
115172
_comp_compgen -c "${cur:-/dev/}" filedir

0 commit comments

Comments
 (0)