On Thu, Sep 25, 2014 at 11:53:18PM -0700, Alexandre Ferrieux wrote:
> Of course, their intention is precisely expressed by the '#!/bin/sh' header

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.

The number of scripts that use #!/bin/sh but then go on to use Bash
syntax is higher than you might believe.  Whether exported functions are
in that toolset, I couldn't say for sure, but it's likely.  Even in the
#bash channel on IRC we have often advocated constructs like this:

  myfunc() { ...; }
  export -f myfunc
  find . -type f -exec bash -c 'for f; do myfunc "$f"; done' _ {} +

(This is in response to "Why can't I do find -exec myfunc", which is
something of a frequently asked question.)

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.

Reply via email to