ma-linux@tux.org
[Top] [All Lists]

Re: [ma-linux] Bash Problem

Subject: Re: [ma-linux] Bash Problem
From:
Date: Tue, 10 May 2005 21:19:39 -0400
On Tue, May 10, 2005 at 11:28:25AM -0400, Charles Shannon Hendrix wrote:
> > i think you've said this, but as a clarification, it all depends upon
> > passing parameters to an executable.  for instance these have no limits:
> > 
> >     echo `ls`
> >     x=`ls`
> 
> That's not true.  Some (most?) shells have a maximum size for
> environment variables.

i have never hit a maximum size and i have flexed it pretty hard, but
you may be right.  since i've never hit a max i assumed it was the amount
of virtual memory available to the shell.

try this:

        echo `cd /; ls -R`

it'll take a while, but it'll run.  likewise, the same is true for:

        x=`cd /; ls -R`

now, try:

        /bin/echo `cd /; ls -R`

btw, i tried these commands on my system before i sent my email.

> > because they're shell builtin's.  the following has a limit based on
> > the number of parameters passed in through argv and the number of bytes
> > permittable in argv:
> > 
> >     /bin/echo `ls`
> 
> No, the limit comes from the shell. argv has no byte limits, it is just
> a pointer.  The system itself might have a limit, but it is usually
> quite high.

try out the attached program (apologies for it's simpleness).  notice
there is no shell involved and execv() will eventually fail.  on my
system that number was 32491 (roughly 2^15):

        $ ./x 32491
        execv: Argument list too long

-- 
Mark Smith
mark@xxxxxxxxxxxxx
mark at tux dot org
nova-instructor at tux dot org

Attachment: x.c
Description: Text document

_______________________________________________
ma-linux mailing list
ma-linux@xxxxxxx
http://www.tux.org/mailman/listinfo/ma-linux
<Prev in Thread] Current Thread [Next in Thread>