Why I hate the Solaris 10 version of /bin/sh

August 23, 2010

Every so often I discover some exceptional piece of braindamage in Solaris. Here is one of them, presented in handy illustrated form:

$ cat cdtest
#!/bin/sh
cd /not/there || echo failed
echo got here

$ sh cdtest
./cdtest: /not/there: does not exist

(No other output is produced.)

Oh yes, Solaris. Killing my script when a cd fails is just what I want you to do, especially when this behavior is undocumented and cannot be turned off. I especially like it when you do this despite me making every attempt to handle the error.

It goes without saying that this behavior is in no way POSIX standard and in no way matches either the historical behavior of the Bourne shell or how the Bourne shell behaves on other systems.

I think that all of our Solaris shell scripts are about to change from '#!/bin/sh' to '#!/usr/bin/bash'. I'm not a huge fan of Bash, but at least it doesn't contain helpful landmines that blow up production scripts.

Written on 23 August 2010.
« My (probably wrong) assumption about Flash on Fedora
A design mistake in my comments form »

Page tools: View Source, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Mon Aug 23 11:56:39 2010
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.