[lug] Remember Y2K?

Jeffrey S. Haemer jeffrey.haemer at gmail.com
Mon Feb 24 16:06:08 MST 2014


Folks,

I just fixed a W08 problem. This morning, a shell script I'd written
started to fail. The problem was a line adding the week-of-year to
something else.

x=$(( $(date +%W) + something_else ))


What could possibly be wrong with that?

Answer: $(date +%W) returns (starting this week) 08 .  Bash says "The
leading zero says you mean 'octal.'  Shame on you. Eight is *not* an octal
number."

That sound you heard around 3:15 this afternoon was me, smacking my
forehead.

My solution was to change it to 10#$(date +%W)

Is there a better solution?

-- 
Jeffrey Haemer <jeffrey.haemer at gmail.com>
720-837-8908 [cell], http://seejeffrun.blogspot.com [blog],
http://www.youtube.com/user/goyishekop [vlog]
*פרייהייט? דאס איז יאַנג דינען וואָרט.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20140224/204e17d6/attachment.html>


More information about the LUG mailing list