I just learned I can process hex and octal string as number:
awk --non-decimal-data 'BEGIN {a="0x0b" ; print 10 * a * "017"}' echo $(( 10 * 0x0b * 017))
1650 1650
10 * 0x0b * 017 = 10 * 11 * 15 = 1650. Its easy, but Bashs arithmetic expansion looks even better in my opinion.
But this is actually not why I am writing this post. The option explanation in manpage sounds very scary:
-W non-decimal-data --non-decimal-data Recognize octal and hexadecimal values in input data. Use this option with great caution!
Is there any security issue or something? Or just because of the mix of the coercion and different number bases may confuse some coders? Well, I dont think I really care since I probably wont use it. But if you know the reason for that scary warning, be sure to tell me!
0 comments:
Post a Comment