Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#191 closed enhancement (fixed)

improve the example to examine smartctl's return code

Reported by: robkehl Owned by: Christian Franke
Priority: trivial Milestone: Release 5.42
Component: smartctl Version: 5.40
Keywords: Cc:

Description

Hello!

Thank you for this brilliant piece of software.

I just want to suggest a minor improvement to the man page of smartctl.

At section "RETURN VALUES" near the end of the man page for smartctl[8], you state an example to examine the error code returned by smartctl:

To test within the shell for whether or not the  different  bits
are  turned  on  or  off, you can use the following type of con‐
struction (this is bash syntax):
smartstat=$(($? & 8))
This looks at only at bit  3  of  the  exit  status  $?   (since
8=2^3).   The shell variable $smartstat will be nonzero if SMART
status check returned "disk failing" and zero otherwise.

Why not show the user a way to examine all error codes by including something like this:

E=$?; for ((i=0; i<8;i++)); do echo "Bit $i: $(($E & 2**$i && 1))"; done

This would produce output like the following:

Bit 0: 0
Bit 1: 0
Bit 2: 0
Bit 3: 0
Bit 4: 0
Bit 5: 0
Bit 6: 1
Bit 7: 0

With kind regards,

Robert Kehl

Change History (3)

comment:1 by Christian Franke, 13 years ago

Keywords: man page improvement removed
Milestone: Release 5.42
Owner: changed from somebody to Christian Franke
Status: newaccepted

comment:2 by Christian Franke, 13 years ago

Resolution: fixed
Status: acceptedclosed

comment:3 by mlissner, 13 years ago

Just chiming in to say thanks - this already helped me, and I haven't even gotten the updated man page yet. Just finding this request was useful!

Note: See TracTickets for help on using tickets.