Re: Exported (ba)sh functions in the environment
On 28/05/12 19:17, Peter Samuelson wrote:
Plus "set" is built-in and so doesn't run in a sub-shell, while "env" is
a program so it is run
On my machine running "set> set.txt&& ls -lsa set.txt" reveals that my
environment contains 225517 of "stuff" - some of it is even being
taken up by
exported function definitions!
As mentioned earlier, 'set' is not reporting much more than the
environment exported to external processes and scripts. Observe:
$ set | wc -c
That's my interactive bash session, including a huge chunk from
$ env | wc -c
That's all that actually gets exported to external processes, including
$ sh -c set | wc -c
$ sh -i -c set | wc -c
That's dash, including the 792 bytes of exported environment noted
earlier. Interactive mode (-i) seems to make no difference.
$ bash -c set | wc -c
$ bash -i -c set | wc -c
...and that's bash, which does a bit more at startup than dash.
Interactive mode (-i) enables bash-completion and other stuff. Big
difference! But probably no shell scripts ever run in interactive
in a sub-shell, so non-exported variables aren't available.
I guess I'm confused as to why bash completion needs these.