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

Re: Exported (ba)sh functions in the environment

[Philip Ashmore]
> 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
bash-completion.  But...

    $ env | wc -c

That's all that actually gets exported to external processes, including
shell scripts.

    $ 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

Reply to: