Weekend
Amy's parents and sister were in town, and we spent Saturday
in San Francisco walking about. We then spent Sunday on the
coast. I love this area, and let me tell you, I keep
finding more to interest me.
What is it with Italian restaurants in Belmont/San Carlos?
Near where we live there are a bunch of such restaurants,
and every single one is rather pricey. Not $30 a plate, but
more than I'd expect for a small place.
However, in the North Beach district of San Francisco are a
ton of excellent cafes/restaurants with prices more
like you'd expect. I guess we'll be going into town for
Italian. The after-dinner options are better anyway.
Scripting
raph
posted a diary entry discussing the slipshod way many people
use scripting languages. He makes many good points, some
I've been bitching about for years.
My favorite is the error checking. I've spent a lot of time
doing sh scripts for dummies. I've been doing sh scripts in
m4 for a long time now, so that I don't have to type out
/bin/foo -bar
if [ "$?" = "0" ]
then
do something good
else
do something because we broke
fi
every single time. People usually don't check
errors because it is tedious. But those errors need to be
caught.
My case was a fun one, because it was root-level sysadmin
scripts that performed complex tasks. Some of the people I
worked with didn't understand or know all the implications,
and I had to have my scripts cover those cases. Lots and
lots and lots of precondition testing and error handling.
I'd have a 400-line script to handle 5 actual command calls.
My scripts never created untenable situations from bad user
input or bad conditions. They just printed a nice error and
said "try again when it's fixed". This is what a good
script should do.
Why sh? Why not perl/python/name-your-own-religion?
Because these admin scripts only called system commands.
The semantics of Perl's system() or the equivalent are
annoying when you just want to run mkdir(1). More complex
items may find me in Perl, but these days I'm quicker to C.
As far as quoting goes, spend some time running commands via
dsh(1), and you'll get your quoting right. Very right.
Quoting isn't hard, you just have to learn the rules.