Re: A good time to switch to dash as /bin/sh?

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



On 26/09/14 07:30, Drake Wilson wrote:
> There is a _lot_ of "magic behavior" in bash.  Debian bug #762839 mentions
> how bash still imports shell functions from environment variables with magic
> names, even when called as sh.  The --posix option seems something of a joke.

Sorry, I mistyped; I meant magic values.

Incidentally this means that any environment variable of that form that
passes _through_ a bash instance to a subprocess will silently get mangled
in transit:

  % env 'foo=() { true; true; }' bash -c "dash -c 'printf %s\\\\n \"\$foo\"'"
  () {  true;
   true
  }

The function definition was reconstructed from some internal form
and reinjected into the environment, as you can see.  And of course during
the bash script itself it's not interpreted as a variable:

  % env 'foo=() { true; true; }' bash -c "printf '%s\\n' \"\${foo-oops}\""
  oops

How much more of this "hidden treasure" is there?

(There might be another approach involving convincing bash upstream to be
much stricter in --posix mode or when invoked as sh or something, but that
seems like a lot more work and less reliable.)

Aside: I'm not sure about the interpretation of checkbashisms re autotools
scripts (in particular libtool) because they do an awful lot of weird code
generation and shuffling to deal with multiple bogus shell implementations.

   ---> Drake Wilson


[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux