FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian Development

 
 
LinkBack Thread Tools
 
Old 05-26-2012, 03:29 AM
Philip Ashmore
 
Default Exported (ba)sh functions in the environment

On 26/05/12 04:14, Russ Allbery wrote:
> I'm curious why even your set of shell variables is so large, though. My
> environment is only 1699 bytes on a system I logged onto via ssh, and
1998

> on my desktop (running Xfce). One of the biggest chunks of that is
> LS_COLORS.
>
Here's where I wish I was a shell script guru:

for var in `cat set.txt`; do
{ if in env discard }
done
{ sort offenders by decending size }

Here's a summary of the ones that caught my eye. Sorry if I missed
anyone out!


_xspecs
__expand_tilde_by_ref()
__gdbus()
__get_cword_at_cursor_by_ref()
__git_complete_remote_or_refspec()
( lots more git functions )
__grub_dir()
_a2dismod()
_apt_file()
_debconf_show()
_dkms()
_hg()
_inkscape()
_insserv()
_module_assistant()
_openvpn()
_pbuilder()
_stg()
_svn()
_update_initramfs()
_valgrind()
_xinetd_services()

Regards,
Philip


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4FC04E32.3010704@philipashmore.com">http://lists.debian.org/4FC04E32.3010704@philipashmore.com
 
Old 05-26-2012, 03:32 AM
Osamu Aoki
 
Default Exported (ba)sh functions in the environment

Hi,

On Fri, May 25, 2012 at 08:14:28PM -0700, Russ Allbery wrote:
> Philip Ashmore <contact@philipashmore.com> writes:
> I'm curious why even your set of shell variables is so large, though. My
> environment is only 1699 bytes on a system I logged onto via ssh, and 1998
> on my desktop (running Xfce). One of the biggest chunks of that is
> LS_COLORS.

It was like that for me until I installed the bash-completion package -
programmable completion for the bash shell.

$ set|wc
7355 19255 218488

HUGE!

Osamu


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120526033204.GA6570@localhost">http://lists.debian.org/20120526033204.GA6570@localhost
 
Old 05-26-2012, 03:34 AM
Russ Allbery
 
Default Exported (ba)sh functions in the environment

Philip Ashmore <contact@philipashmore.com> writes:

> Here's where I wish I was a shell script guru:

> for var in `cat set.txt`; do
> { if in env discard }
> done
> { sort offenders by decending size }

> Here's a summary of the ones that caught my eye. Sorry if I missed
> anyone out!

Oh. This is smelling like artifacts of bash-completion; perhaps set is
dumping your completion settings. I'm pretty sure those are not copied
into subshells and are only loaded in interactive shells.

--
Russ Allbery (rra@debian.org) <http://www.eyrie.org/~eagle/>


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 87ipfjr4xg.fsf@windlord.stanford.edu">http://lists.debian.org/87ipfjr4xg.fsf@windlord.stanford.edu
 
Old 05-26-2012, 03:45 AM
Philip Ashmore
 
Default Exported (ba)sh functions in the environment

On 26/05/12 04:34, Russ Allbery wrote:
> Philip Ashmore <contact@philipashmore.com> writes:
>
>> Here's where I wish I was a shell script guru:
>> for var in `cat set.txt`; do
>> { if in env discard }
>> done
>> { sort offenders by decending size }
>> Here's a summary of the ones that caught my eye. Sorry if I missed
>> anyone out!
> Oh. This is smelling like artifacts of bash-completion; perhaps set is
> dumping your completion settings. I'm pretty sure those are not copied
> into subshells and are only loaded in interactive shells.
>
In my original email I ran "set > set.txt && ls -lsa set.txt".

Putting the same into a script:
#!/bin/sh
set > set.txt && ls -lsa set.txt

...got me 2353 bytes - I'll be a donkeys ass!

It looks like the fact that I typed it made it interactive, even though it
didn't require/allow any interaction.

Thanks,
Philip


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4FC051DA.6060104@philipashmore.com">http://lists.debian.org/4FC051DA.6060104@philipashmore.com
 
Old 05-28-2012, 06:17 PM
Peter Samuelson
 
Default 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.


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120528181744.GB3644@p12n.org">http://lists.debian.org/20120528181744.GB3644@p12n.org
 
Old 05-28-2012, 06:39 PM
Philip Ashmore
 
Default Exported (ba)sh functions in the environment

On 28/05/12 19:17, Peter Samuelson wrote:


[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.
Plus "set" is built-in and so doesn't run in a sub-shell, while "env" is
a program so it is run

in a sub-shell, so non-exported variables aren't available.

I guess I'm confused as to why bash completion needs these.

Philip


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4FC3C66E.1040700@philipashmore.com">http://lists.debian.org/4FC3C66E.1040700@philipashmore.com
 
Old 05-28-2012, 07:44 PM
Peter Samuelson
 
Default Exported (ba)sh functions in the environment

[Philip Ashmore]
> I guess I'm confused as to why bash completion needs these.

Easy enough to read /etc/bash_completion and /etc/bash_completion.d/*
and see for yourself why it needs these.

bash-completion is full of special cases to "do the right thing" in
hundreds or thousands of different circumstances. If it were as simple
as "offer a list of filenames when you hit tab", that's already built
in to bash and we wouldn't need bash-completion as a separate package.

As a _very_ simple example, if you type 'kill <tab>', you get a list of
current process IDs. If you type 'kill -<tab>', you get a list of
signals, plus the common options -l and -s.

If you can think of a way to implement this same stuff (and remember,
bash-completion supports a _lot_ more complex cases than 'kill')
without adding 200 kB of shell functions to bash's runtime, by all
means, do it and see how it works out.

Peter


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120528194448.GC3644@p12n.org">http://lists.debian.org/20120528194448.GC3644@p12n.org
 
Old 05-29-2012, 01:18 AM
Miles Bader
 
Default Exported (ba)sh functions in the environment

Peter Samuelson <peter@p12n.org> writes:
> If you can think of a way to implement this same stuff (and remember,
> bash-completion supports a _lot_ more complex cases than 'kill')
> without adding 200 kB of shell functions to bash's runtime, by all
> means, do it and see how it works out.

What would seem interesting would be a way to autoload bash completion
support for each command ... as it would seem not uncommon to have shell
sessions where the user never tries to use completion for 99% of the
commands handled.

[or does it already do this?]

-miles

--
Consult, v.i. To seek another's disapproval of a course already decided on.


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 87obp7aioj.fsf@catnip.gol.com">http://lists.debian.org/87obp7aioj.fsf@catnip.gol.com
 
Old 05-29-2012, 01:39 AM
Paul Wise
 
Default Exported (ba)sh functions in the environment

On Tue, May 29, 2012 at 9:18 AM, Miles Baderwrote:

> What would seem interesting would be a way to autoload bash completion
> support for each command ... as it would seem not uncommon to have shell
> sessions where the user never tries to use completion for 99% of the
> commands handled.
>
> [or does it already do this?]

It already does this:

http://packages.debian.org/changelogs/pool/main/b/bash-completion/current/changelog#version1:1.90-1

--
bye,
pabs

http://wiki.debian.org/PaulWise


--
To UNSUBSCRIBE, email to debian-devel-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: CAKTje6FuWBC4JjXTMkSxpnXL91rtB8f-+-JY_jpTyZixuCacgA@mail.gmail.com">http://lists.debian.org/CAKTje6FuWBC4JjXTMkSxpnXL91rtB8f-+-JY_jpTyZixuCacgA@mail.gmail.com
 

Thread Tools




All times are GMT. The time now is 02:57 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org