On Mon, Oct 10, 2011 at 11:06:16AM -0400, Len Giambrone wrote:
> I understand that.  But if you change all your scripts to use
> 
> #!/bin/bash
> instead of
> #!/bin/sh
> 
> your scripts will fail when bash isn't installed.

If you use bash features in your script, then you must ensure that the
script is executed by bash, and not by /bin/sh.  There are many ways you
can accomplish this:

1) Use #!/usr/bin/env bash in the shebang.

2) When installing the script, determine where bash is installed, and put
   the path to bash in the shebang.

3) Install two scripts.  The first is a wrapper that contains:

   #!/bin/sh
   exec bash /the/other/script ${1+"$@"}

4) Attempt to re-exec yourself in bash if you determine (at run time) that
   you are not in bash.

Those are roughly in order of desirability/possibility.

If /bin/sh is dash, or ksh, or a Solaris pre-POSIX Bourne shell, then
no amount of filing bug reports on bug-bash is going to help you.

If you use /bin/sh as your shebang, you MUST write your code to target
either the POSIX or the Bourne set of features.

Reply via email to