From: Chris D. <ch...@ch...> - 2014-01-16 03:28:29
|
On 2014-01-15 19:09:21 +0100, Christian Franke wrote: > No, the exponentiation operator (2**i) is also not part of POSIX. Good catch, I missed that. > It would probably make sense to use a more portable example, e.g.: > > val=$?; mask=1 > for i in 0 1 2 3 4 5 6 7; do > echo "Bit $i: $(((val & mask) && 1))" > mask=$((mask << 1)) > done That looks good to me. You could also use `let i++' and `[ "$i" -lt 8 ]', but I don't think it offers much advantage. |