One of the strangest bugs…

One task that I’m currently working on is a linux shell script that sets up a bunch of stuff for a deployment environment. Part of the setup involves creating a bash script that is used on a post-receive hook in git. In short, any time something is received by git it runs the script.

Things with the overall bash script were going well, until I noticed something odd. One particular line in the bash script was getting changed somewhere between the machine I was writing it on and the server. There was a single line of the script that contained the following line:

git checkout -f

Somehow, when looking at the results from running the bash script on the server, it was instead producing this:

git checkout 96f

Not even close to being the same! At first I thought it was something that Ubuntu was doing to that particular line. Could it be somehow mangling things because I wasn’t properly escaping the dash symbol? Could it be that I was having to run dos2unix to alter line endings after getting it to the server? No matter how much digging I did, there was no clue to what was going on. That was when I noticed something.

When I examined the file immediately after transferring it over (through FileZilla), I noticed that it still said “96f” – even before running dos2unix on it. This meant that somewhere in the transfer it was getting mangled. But why would FileZilla care what the file contents were? Especially this one character? Something still seemed fishy. Just to make sure I was looking at the right file, I threw in a few other characters on either side, so it looked something like this:

git checkout adasdf-fasdfas

I sent that across to the server, and it by the time it got to the server side it looked like this:

git checkout adasdf96fasdfas

What the heck?! Even trying different ftp modes – ascii, binary – showed the same result. It then occurred to me…

That little particular snippet of code was copied from a GitHub wiki page. That dash wasn’t actually a dash – it was some other strange unicode character! I promptly deleted the offending line, re-wrote it, and sent it across to the server, and voila – it all worked!

I think this still stands out as being one of the most bizarre bugs I have seen in a long time.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s