I tend to agree with you. When I write scripts, I target sh, not bash. If it doesn't fit in sh, then I look at a dedicated scripting language (perl/ruby/python) that will almost certainly be a better fit.
Most shell scripts are a collection of undeclared external dependencies. You can't really rely on sed, awk, and grep to behave the same way on Linux as they do on Solaris or AIX.
It seems like if you're concerned with portability, you shouldn't be writing a shell script in the first place.
Re:Miguel de Icaza: Learning Unix
by peterwwillis on Wednesday September 07, 2011 @12:57PM
(#2970281)
Au contraire, shell script in a (real) POSIX environment is one of the most portable things... It's interpreted and there's always some kind of shell on any Unix system, unlike other interpreted languages. That's why lots of 3rd party vendors use shell scripts to package their setup tools.
Yes the tools behave differently on different systems, but 99.9% of the time there's very basic syntax that is respected across all versions of the tools. Stick to BSD4.4 C Shell syntax (http://docs.freebsd.org/44doc/usd/04.csh/paper.html), don't rely on regular expressions in grep, and stick to the very basics of sed and awk and you can go pretty far in Unix.
Any of the following commands which existed on some archaic version of Unix will still exist and their limited but useful functionality can be extended in lots of ways, and is pretty darn portable. https://secure.wikimedia.org/wikipedia/en/wiki/List_of_Unix_...
Re:Miguel de Icaza: Learning Unix
by tequilarection on Wednesday September 07, 2011 @06:56PM
(#2971893)
Except that Perl changes often. There are regular major releases of perl itself, and countless actively maintained modules.
On the other hand, Perl rarely changes. If you find yourself forced into a Perl 4 system you can still use the basics of Perl 5. IMO, if you have a relatively complex job to perform, Perl is going to be more reliable than Bash.