Command line expansion.
utzoo!decvax!ucbvax!unix-wizards
utzoo!decvax!ucbvax!unix-wizards
Sun Dec 27 00:05:17 AEST 1981
>From decvax!yale-comix!bj at 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.
More information about the Comp.unix.wizards
mailing list