Apr 142011
 

Today I was trying to help someone with a regular expression to match an e-mail address.  He was developing on a Solaris server and sent me the regular expression outlined in RFC 822 which outlines message formatting for e-mail headers.  The command he sent me to test with took a little tweaking, but I eventually came up with:

Pretty straight-forward.  Search for any alphanumeric, dot, underscore, percent sign, plus sign, or dash, repeating one or more times followed by an ‘@’ sign, then another alphanumeric, dot or dash, repeated one or more times, a dot, and then an alphabetical character repeated 2, 3, or 4 times.

The thing that gets me is that this command worked on my Mac.  It worked on a Linux server.  I sent it back to him, he tried it, and… it didn’t work.  After poking around a little bit, I determined that it was because on Solaris for this to work correctly, you need to use /usr/xpg4/bin/egrep rather than /bin/egrep, which brings me to the original reason for this post.  On Solaris, there are no fewer than four places where you may find standard OS commands – /bin, /usr/xpg4/bin, /usr/ucb, and /usr/sfw/bin.  A couple other third party distributors will also package core OS utilities (like the GNU toolset) and install them in their own directory under /opt.

Larry Ellison and His Sausage

Larry Ellison - It's his sausage, but it's not his fault.

 

I’d like to blame Oracle for this, but quite frankly, Sun has been doing this since I can remember with Solaris 2.5.1, which is the earliest version I’ve worked with.  I’ve been getting annoyed by this quite frequently lately, and it was finally time for me to vent.  Thank you for listening and remember, when you are on Solaris and you want to run a basic command, you must choose.  But choose wisely.  Today, with /bin/egrep, I chose… poorly.

  One Response to “Why I Hate Solaris – Reason #1”

  1. Ideally there should be only one grep command, but there is not a single algorithm that spans a wide enough range of space-time tradeoffs.

Sorry, the comment form is closed at this time.