Always use Bourne shell in init scripts for Solaris

Many years ago, one Unix interviewer told me that Bourne shell should be used for best compatibility across different UNIXs.  That certainly is still true today. For example, only Bourne shell (sh) is accepted in init scripts for Solaris. Here is one explanation that I heard so far: During the bootstrap process, /usr isn’t mounted. Therefore shells such as Bash (/usr/bin/bash) won’t work. Bourne shell (/sbin/sh) will work. So be aware of this difference when you work across different UNIXs and Bourne shell is a good bet for compatibility.

Special thanks to Hans N. for the explanation.


3 thoughts on “Always use Bourne shell in init scripts for Solaris

  1. When the sh-bang (line that starts with #! ) line is not present, an init script is interpreted under Bourne shell; that is the default behavior. This may be the reason it is recommended to use the Bourne shell because it is available in all version of UNIX in single user mode when /usr is not necessarily mounted. Also, it is noteworthy that files living in /sbin are statically linked (dynamically linked binaries require LD_LIBRARY_PATH to the be set to /usr/lib at minimum and possibly including /usr/local/lib for s/w complied from tar-balls). My favorite book on shell programing is “Portable Shell Programming: An Extensive Collection of Bourne Shell Examples by Bruce Blinn” Pub. Date: October 1995; HP Press. Another definitive book on shell programming is “Classic Shell Scripting: Hidden Commands that Unlock the Power of Unix by By Arnold Robbins, Nelson H.F. Beebe”; Pub Date May 2005; O’Reilly (Robbins is the author of O’Reilly’s ever popular “sed and awk” as well as “sed and awk Pocket Reference”). Prior to those two books, O’Reilly’s “Unix Power Tools” was the first book I learned Bourne shell programming (Chapters 27-37).
    “The Bourne shell, or sh, was the default Unix shell of Unix Version 7” from – Another relatively recent book on shell scripting “Wicked Cool Shell Scripts 101 Scripts for Linux, Mac OS X and Unix Systems” by Dave Taylor, Pub Date: Jan 2004, No Starch Press. According to the Single UNIX Specification “The standard user command line and scripting interface is the Bourne Shell.” – Apple stated that the will pursue UNIX ’03 certification for the upcoming release of Mac OS X 10.5; Mac OS X 10.5 will include Bootcamp free of charge to run Windows.

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