Handling arguments with spaces in bash

Way to often I get it wrong, so I decided to right this down…

When processing the list of arguments in your bash script, remember that often arguments such as file names contain spaces. The wrong way to go about this is:

#!/bin/bash
for FILE in $*
do
  echo "$FILE"
done

The right way to do it is:

#!/bin/bash
for FILE in "$@"
do
  echo "$FILE"
done

Advanced Bash-Scripting Guide explains the difference in “Internal Variables” chapter.

Possible downtimes ahead

Here is a quote from an email notification I received from my provider regarding my Internet connection:

Please note that due to scheduled maintenance works on our international links, connectivity is subject to an outage during the following periods:

Friday, May 27th 2005, from 07:30 to 08:30 Cyprus time (GMT +0300).

Saturday, May 28th 2005, from 01:30 to 02:30 Cyprus time (GMT +0300).

On tuning

Today while walking with Maxim, I passed by a municipal parking. There was nice looking car. I came closer to have a good look at it. It was Honda Accord with all the sport-looking things you can imagine – rims, tires, spoilers, stickers, etc. It looked like a really fast car. Very aggresive too. I walked around it and looked inside. And guess what I saw inside? You’ll never guess – an automatic gearbox! Suddenly I lost all my interest in the car…

Alarm sounds

For the last two hours I was enjoying the sounds of alarm that went off in our building. Since it started in the middle of the night, noone except me noticed it. I let it ring for about 10 minutes before calling the building security. They guy hasn’t noticed it, since it was ringing only in one building, on one floor, and one office. He came and tried to disable it, but failed. Than he spent about 20 minutes on the phone trying to wake up his superior. Another half an hour passed before the superior came and tried to disable it. Needless to say he failed too. Meanwhile I was still listening to the warbles of bells and whistles…

Finally, about two hours into the concert, they managed to switch the damn thing off. I think they used every available tool in the office, from a mere pencil and to a professional drilling machine. But I don’t really care as long as that thing keeps silent.

Platypus plugin for Mozilla Firefox

Platypus plugin must be one of the coolest plugins for Firefox that I’ve seen around. It allows the user to modify the appearence of the website and save the chages. Here is a small feature overview from plugin’s page:

Some of the things you can do with Platypus include:

  • Remove parts of the page you don’t wish to see.
  • Move a part of the page to a different location.
  • Change the style and format of page elements.
  • Modify all the links on the page using a regular expression.
  • Insert your own HTML code.

I’ve found it via this post.