He hasn't said so explicitly, but I've gained the impression that mohtashims has been required to maintain and port a lot of shell scripts not all his own devising, and hopes for cookie-cutter solutions for scripts written using non-portable options.
There a few strategies you can try.
- Substituting different commands on different systems.
- Building your own substitutes for every troublesome command.
- Re-factoring the scripts to use actually portable options.
Solution #1 obviously
looks easier and more attractive, since hypothetically it can be done with just a "header" section and few to no changes to large amounts of code you may not necessarily understand. But if it really was better, you would have solved your problems months ago. You must be dealing with a large number of very different systems, as you're still finding and plugging hole after hole, and will continue to do so for a long time. What will you do when you hit one which doesn't have GNU extensions available?
Solution #2 is a big job. I've spent large amounts of time duplicating
one command.
Solution #3 unfortunately means having to understand what grep -o actually means, so as to replace it. You may want to break it down and test commands individually rather than fighting it as one gigantic block of code.
My last comment: This is what happens when you try and detect and compensate for every difference between systems:
That's 800 kilobytes of ad-hoc corrections per decade, more or less.