[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
    189097

That's my interactive bash session, including a huge chunk from
bash-completion.  But...

    $ env | wc -c
    792

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

    $ sh -c set | wc -c
    908
    $ sh -i -c set | wc -c
    908

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
    1371
    $ bash -i -c set | wc -c
    189101

...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
mode.


Reply to: