bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: exported SHELLOPTS gives error message from sh


From: Greg Wooledge
Subject: Re: exported SHELLOPTS gives error message from sh
Date: Mon, 10 Oct 2011 11:15:04 -0400
User-agent: Mutt/1.4.2.3i

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

[Prev in Thread] Current Thread [Next in Thread]