unix question: files per directory

Brandon S. Allbery allbery at ncoast.ORG
Fri May 5 08:54:31 AEST 1989


As quoted from <432 at brian386.UUCP> by news at brian386.UUCP (Wm. Brian McCane):
+---------------
| >Another thing you may run into is that some UNIX utilities seem to store
| >the names of all of the files somewhere before they do anything with them,
| 
| You didn't actually run into a "rm" bug/feature, you hit a shell
| FEECHER.  The shell expands for the regexp, and then passes the
| generated list to the exec'd command as the arguments.  "rm" can only
| handle a limited number of files, (or it may be the shell will only pass
| a limited number, who knows, its a FEECHER after all ;-), so rm then
+---------------

Sorry, it's a kernel limitation.

The combined size of all elements of argv[] must be less than some size
(I have seen 1024, 5120, and 10240 bytes on various systems).  This limit is
enforced by the execve() system call (from which all the other exec*() calls
are derived).  If the argument list is longer than this limit, exec()
returns an error which the shell (NOT rm) reports back to the user.

+---------------
| gave the error message of too many filenames.  I would like it if "rm"
| were similar to most other commands, ie. you could rm "*", preventing
| the expansion of the * to all file names until "rm" got it, but it
| returns the message "rm: * non-existent" on my machine, Sys5r3.0.
+---------------

Most other WHAT commands?  MS-DOS?  VMS?  *Certainly* not Unix commands.

The advantage of making the shell expand wildcards like * is that the code
need only be in the shell, and not enlarging the size of every utility which
might have to parse filenames.  In these days of shared libraries, that may
not be as necessary as it used to be; however, having it in one place does
insure that all utilities expand filenames in the same consistent way
without any extra work on the part of the programmer.

++Brandon
-- 
Brandon S. Allbery, moderator of comp.sources.misc	     allbery at ncoast.org
uunet!hal.cwru.edu!ncoast!allbery		    ncoast!allbery at hal.cwru.edu
      Send comp.sources.misc submissions to comp-sources-misc@<backbone>
NCoast Public Access UN*X - (216) 781-6201, 300/1200/2400 baud, login: makeuser



More information about the Comp.unix.wizards mailing list