Misleading text: $(()) is not bash specific

Chris Down <[email protected]>
Newsgroups gmane.linux.utilities.smartmontools
Message-ID <[email protected]>
Hello,

In the "RETURN VALUES" section of the manual page for smartctl(8), it is
stated:

       To test within the shell for whether or not the different bits
       are turned on or off, you can use the following type of
       construction (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.

       This bash script prints all status bits:
       status=$?
       for ((i=0; i<8; i++)); do
         echo "Bit $i: $((status & 2**i && 1))"
       done

All references to bash should be removed and replaced with notes that
this is instead *POSIX* shell syntax -- this code works in all POSIX
shells. See section 2.6.4 of POSIX[0].

Perhaps this was confused with `((', which is indeed not POSIX (although
it is also not bash-specific).

Thanks.

[0]: http://pubs.opengroup.org/onlinepubs/009604599/utilities/xcu_chap02.html#tag_02_06_04

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk

_______________________________________________
Smartmontools-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/smartmontools-support
signature.asc (application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iQIcBAEBAgAGBQJS1glOAAoJEMbcxX5GyInGuZsP/i4GDNDoWFSr6w+h07v+azW6
kI/YQ3hA5bKpUICAtHJ3UlPMNL1giNVG0drNkE7SmH2nV1smzl+U+qkKeRc2VT7b
TPRhUl/evceLOmdJ3u8HIyZLUMVQRnhcVwaXbZETxuTz9x3VJeX/U8sWZUxWOTxP
ARiunAChRklrdRByFvls4iKuBuLf550I/ZrTvRScBupM8XFFNh545hoa597YGH+q
zZ3FAWbuujzUHtlGVzpsowQKBrSDdBkmnk5HbfsNSawMvze15pblUSauF0tuuqgL
1gWsIBd5i7WMptvkJx7hJn8JiMRH4jMzX4GWTDsPVD6Lf5PyJApFuX8Z2PWyUUf3
ikFL9P6DPyilIcqS5pYOBEvw4zJ5WOM9onfCqagBFoiDiU4H0nQqgE/YvXrmmY3X
AtxxDEzQt3H0GDnJF7sr33EG5z5u/uNYBhbCZbgbjHRaS1W6+FWZCvNIfJnjbbsv
X/C4E7BrjzLJ2MJCsed9ssRv36F9DcjFYvUA1RDmdnKJIzggc7bvITM0En9LttCg
QKl4FrYJil/yUjoSmMygE48Y2npwCapmkKDSkHPWpTXu/VG30JvdYYIcqhjgsqdi
7y4/aI93hLoRRyQsB5ZnAO6SePVUxw78N989gK0+9G26hsOHHrbeO59lNoxFwvTm
yF2E1O05FKTtbKsmlbqF
=WRaA
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.