[Top][All Lists]

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

Re: Detecting invocation as /bin/sh ?

From: Bob Proulx
Subject: Re: Detecting invocation as /bin/sh ?
Date: Tue, 30 Sep 2014 16:14:04 -0600
User-agent: Mutt/1.5.23 (2014-03-12)

Alexandre Ferrieux wrote:
> Greg Wooledge wrote:
> > Unfortunately, most people don't actually express an intent when they
> > use #!/bin/sh.  They just copy some code from a random script they found
> > somewhere, without understanding what it means.
> That song reminds me of PHP. I was under the optimistic assumption
> that bash, given its noble ancestry, was not exactly targeting the
> same audience.

The shell is part of the landscape.  It has been around since the
beginning.  Although some try to avoid it others embrace it.  It is
not a matter of targeting an audience.  It is simply the way things

> > The number of scripts that use #!/bin/sh but then go on to use Bash
> > syntax is higher than you might believe. 

Agreed.  But those are not portable.  And they are one of the reasons
behind dash and the other targeted shells.

> OK. Sh*t happens. Bozos write scripts. So what ?
> A more interesting question IMO is:
>  How many packaged init scripts / mission-critical daemons are
>  written by people that cannot be bothered to write #! /bin/bash
>  when they require bash ?

Lots and lots and lots.  When Debian converted from /bin/sh being bash
over to it being dash there were many bugs found.  The process of
getting those instances cleaned up took a long time.  Years.

> > It's not a stretch of the imagination to suppose that someone has used
> > exported functions in a #!/bin/sh script on a Linux box where /bin/sh
> > is a symlink to bash.
> Except that script would instantly break if *dash* was installed,
> instead of bash, as target of the sh symlink. So that beast would
> already be extremely fragile.

Agreed to both.  Definitely fragile.  But people do it just the same.
Personally I would vote to have bash not support exported functions in
/bin/sh mode.  But as Chet has indicated the task of maintaining a
stripped down shell is the target of dash and posh and others and not
the target for bash.  It would be duplicated effort if bash also
targeted that too.  So while bash might or might not do some of that
it isn't really the project for it.


reply via email to

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