Limitations on a command line

Cathey, Jim jcathey at ciena.com
Sat Jan 29 01:31:38 UTC 2011


>I've worked out that while the code uses full paths to move the files
>about, it uses relative paths in the zip command.
>
>so that's 2000 * 50 in the absolute worst case.
>
>It would be nice to know what length of command might break busybox,
but
>failing that I'll stick an xargs in the command line and pray loudly
:-)

There's _two_ places that can croak: busybox, and
the kernel's argument buffer.  Xargs is supposed to
keep it to a manageable level so far as the kernel is
concerned, it's up to busybox (and any other shell)
to handle that system-defined size.

For any kind of a system script that can't know what it
can reasonably expect to see (i.e. worst case scenarios)
you should never use shell globbing, but rather find
and xargs.  They will never fail.

e.g. What does "rm -f /tmp/*" do if there are 12,000,000
files in the /tmp directory?  (Hint: nothing good!)
Whereas "find /tmp -mindepth 1 -maxdepth 1 ! -type d -print0 \
              | xargs -r0 rm -f" will succeed.  More
complicated, to be sure, but more robust.

-- Jim






More information about the busybox mailing list