sundrag@risky.Convergent.COM (Sundaraswaran Gopalakrishnan) (04/17/91)
Hi, I would like to know how exactly Shell expands the wildcard characters in the command line. Are there any undocumented system calls to accomplish this ? Or the Shell does a physical read of the disk inodes etc. and matches the file name against each one ? Thanks, Sundar.
tchrist@convex.COM (Tom Christiansen) (04/17/91)
From the keyboard of sundrag@risky.Convergent.COM (Sundaraswaran Gopalakrishnan): :Hi, : I would like to know how exactly Shell expands the wildcard :characters in the command line. Are there any undocumented system :calls to accomplish this ? Or the Shell does a physical read of the :disk inodes etc. and matches the file name against each one ? Huh? What do named have to do with inodes? It reads the names from the directory, and compares against these. --tom
jik@athena.mit.edu (Jonathan I. Kamens) (04/18/91)
In article <4056@risky.Convergent.COM>, sundrag@risky.Convergent.COM (Sundaraswaran Gopalakrishnan) writes: |> I would like to know how exactly Shell expands the wildcard |> characters in the command line. Are there any undocumented system |> calls to accomplish this ? Or the Shell does a physical read of the |> disk inodes etc. and matches the file name against each one ? There are C library functions for reading the entries in a directory. On most systems, "man opendir" or "man readdir" will give you a starting point from which to learn more about them. The shell opens directories using opendir(), reads the entries in the directory and compares the pattern it is trying to match against each of them. There's nothing magic involved; no special system calls, no reading of inodes. -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710
guy@auspex.auspex.com (Guy Harris) (04/20/91)
> The shell opens directories using opendir(), reads the entries in the >directory and compares the pattern it is trying to match against each of them. Some old and, at this point, fairly tired versions of UNIX don't have "opendir()" or "readdir()" (yes, you can interpret this as meaning that I believe that V7 is "old and tired" at this point); if you're unlucky enough to be stuck with a system without it, some publicly-available implementations of "opendir()" and "readdir()", at least for systems with V7-ish directory formats, are available. (Doug Gwyn's is the main one out there.) Most flavors of UNIX don't come with routines to do the pattern matching that the shell does; some do, but they may not all put them in the same place. I think publicly-available routines to do that are also available. > There's nothing magic involved; no special system calls, Well, some UNIX systems may use a special system call to implement "readdir()", but that's hidden behind "readdir()", which is what somebody who wants to read the entries in a directory should use.