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

Re: dash-as-bin-sh



On 2010-04-20 11:37:31 -0400, Wes Garland wrote:
> > Bash is still an essential package last I checked.  You might simply use
> > /bin/bash and whatever bash-isms you like.
> >
> That would work pretty much everywhere except bone-stock Solaris,
> where I have no possibility of recovery -- "/bin/bash: bad
> interpreter: No such file or directory".

That wouldn't even work everywhere under Linux. For instance, bash
isn't installed by default on Maemo.

> I suppose my other alternative is roughly  [ -x /bin/bash ] && /bin/bash $0
> $* && exit $?, and assume that everywhere-but-solaris has /bin/bash. Hmm.

[ -x /bin/bash ] && exec /bin/bash -- "$0" ${1+"$@"}

But you also need to detect whether you are not running bash via
this line, otherwise you'll get an infinite loop. I think this can
be done with an environment variable, something like:

  [ "$RUNNING_BASH" = yes ] || [ -x /bin/bash ] && \
    exec env RUNNING_BASH=yes /bin/bash -- "$0" ${1+"$@"}

(not tested). You can also test features, like in:

  ( [[ -n 1 && -n 2 ]] ) 2> /dev/null || exec bash -- "$0" ${1+"$@"}

> If debian keeps bash around as a default package, even when
> dash-is-bin-sh, then I guess I'm in fairly safe territory in that
> regard.

It would probably remain as a default package, but I don't see why
it should remain as essential in the long term.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)


Reply to: