Text File

Aucbvax.5568 fa.unix-wizards utzoo!decvax!ucbvax!unix-wizards Sun Dec 27 00:05:17 1981 Command line expansion. >From decvax!yale-comix!bj@Berkeley Sat Dec 26 23:52:22 1981 One option to having the shell do file name expansion is to have the patterns passed to the programs and have routines that the programs could use to expand the file names. For example char *nextfile(pattern) char *pattern; would return all possible files that matched the pattern, one at a time with a NULL returned after the last one. The routine could take other arguments which specify requirements the files must meet (executable only, directories only, etc.). Other routines could be written to return all the file names at once or to return the user names that match the pattern.

This solution has the following advantages: 1) It reduces the need for quoteing (and knowing when to quote). 2) Allows commands like "cp * *.save". 3) Lets programs check for possible errors like "rm *". 4) Gives the programs more control of the expansion (only directories). 5) Allows wild cards to be used (easily) on things other than file names.

Of course this solution makes programming harder. Every program that uses the command line would have to do a double loop, go through each argument on the command line and expand it. B.J.

----------------------------------------------------------------- gopher://quux.org/ conversion by John Goerzen <jgoerzen@complete.org> of http://communication.ucsd.edu/A-News/

This Usenet Oldnews Archive article may be copied and distributed freely, provided:

1. There is no money collected for the text(s) of the articles.

2. The following notice remains appended to each copy:

The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996 Bruce Jones, Henry Spencer, David Wiseman.