Skip to content

Commit 6e26d97

Browse files
authored
Removing extra shell command; Use bash builtin for extracting a substring (#221)
Removing extra shell command; Use bash builtin for extracting a substring Signed-off-by: Mykhailo Kravchuk <[email protected]>
1 parent 6b36c81 commit 6e26d97

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: smartmon.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,13 @@ format_output() {
167167
awk -F'{' "${output_format_awk}"
168168
}
169169

170-
smartctl_version="$(/usr/sbin/smartctl -V | head -n1 | awk '$1 == "smartctl" {print $2}')"
170+
smartctl_version="$(/usr/sbin/smartctl -V | awk 'NR==1 && $1 == "smartctl" {print $2}')"
171171

172172
echo "smartctl_version{version=\"${smartctl_version}\"} 1" | format_output
173173

174-
if [[ "$(expr "${smartctl_version}" : '\([0-9]*\)\..*')" -lt 6 ]]; then
175-
exit
174+
# Exit if "smartctl" version is lower 6
175+
if [[ ${smartctl_version%.*} -lt 6 ]]; then
176+
exit 0
176177
fi
177178

178179
device_list="$(/usr/sbin/smartctl --scan-open | awk '/^\/dev/{print $1 "|" $3}')"

0 commit comments

Comments
 (0)