Newsgroups: comp.unix.questions Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!mintaka!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Subject: Re: Wildcard Expansion By Shell Message-ID: <1991Apr17.174147.16367@athena.mit.edu> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology References: <4056@risky.Convergent.COM> Distribution: usa Date: Wed, 17 Apr 91 17:41:47 GMT Lines: 21 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