Introduction
Introduction Statistics Contact Development Disclaimer Help
mkphlog v0.3 and bug wrangling
Wednesday, Jan 18 04:34:03 pm, 2012
This weekend, chals emailed me with a bug in the new mkphlog. For s
odd reason, it would only automatically add 7 posts to the main phl
listing before failing miserably to write the new posts to the list
Now, the the easy thing would be to disable that function with the
boolean variable provided in the new version of mkphlog. But I want
fix the script, so I had to do some light debugging. However, what
found was interesting.
[Skip the next 3 paragraphs if you don't want to hear the gory,
slightly dramatized details]
The mistake I made is that I made an assumption in writing the orig
script. For those not really into programming, _never_ make
assumptions. Sometimes you're right, but when you're wrong, you're
scratching your head in confusion. The assumption I made was that t
output of `wc -l` is always the same. It isn't, especially on NetBS
(SDF's operating system), but what's worse is that it isn't standar
across platform. (The wc on Slackware doesn't output the same thing
the wc on NetBSD).
The problem with this is that the program would work fine on NetBSD
until a certain line number was reached (10, or anything above one
digit). Then cut, when trying to split the output into a set number
of fields with a space character as a deliminator, would be one
field off and extract sweet nothing from the `wc -l` output.
It didn't even work at all on Slackware where there is no odd
formatting at the beginning. Which led me to fix the whole issue
with a few simple sed substitutions; just get rid of everything
that I don't want until there is nothing left but the line count.
Let this be a lesson. Be careful how you program :) and don't make
assumptions. That would be a good start. And above all else, have f
coding.
Download mkphlog v0.3 here
You are viewing proxied material from sdf.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.