Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!mintaka!spdcc!iecc!Postmaster From: johnl@iecc.cambridge.ma.us (John R. Levine) Newsgroups: comp.arch Subject: Re: UNIX mind-set -> OK, OK! Message-ID: <9101141022.AA02013@iecc.cambridge.ma.us> Date: 14 Jan 91 15:22:24 GMT References: <1991Jan13.113349.21937@ims.alaska.edu> <11305@lanl.gov> <1991Jan14.013815.11419@ims.alaska.edu> Sender: Postmaster@iecc.cambridge.ma.us Organization: I.E.C.C. Lines: 48 In-Reply-To: <11314@lanl.gov> In article <11314@lanl.gov> you write: >Yes, both of the shells that are bundled with versions of UNIX _do_ >automatically trash (that is, 'process') the command line arguments to >expand wildcards. ... This is a choice that _should_ be left to the >discretion of the utility writer. Ah, finally an issue of software architecture appears in this argument. The theory that the program rather than the command interpreter should decide which arguments should be expanded and which ones shouldn't appears plausible on the surface. Having used both systems that do globbing in the shell (various forms of Unix) and systems that do globbing in the program (TOPS-10, Twenex and MS-DOS, among others, anyone else ever use DOS-11?) I can report that the Unix approach is far superior for several reasons: Consistency: The Unix approach is easy to remember, all arguments are expanded unless quoted. On MS-DOS, some programs expand and some don't, and you have to remember the rules for all of them. The treatment of environment variables is so confused that I don't even want to think about it. (Even Unix suffers here, my editor expands *foo arguments but not $foo when reading file names interactively from the terminal.) Simplicity: If programs do globbing, now each program has to have some way to inhibit globbing for part or all of its filename arguments, so now you have to put quoting facilities into every program or into the filenames themselves. The baroque VMS name syntax is an example of where this leads. Effectiveness: If I were the first programmer writing "echo" I might well say to myself there's no need to expand these arguments, they're just text strings. In fact, one of the most common uses of Unix echo is to expand file name patterns, something you can't do with MS-DOS echo for exactly this reason. Compatibility: When the file name syntax is extended, typically because of a new kind of file system network facility, you only have to fix a few programs, mostly the shells, to handle the new syntax. On MS-DOS, there are still programs that expand wild cards but only in the current directory. Twenex solved this problem by making globbing a system call, but Twenex made everything else a system call, too, so that doesn't prove much. The Unix approach that has a system call to retrieve directory entries but leaves all the rest of the string munging in the application is a fair compromise. One hopes that shared libraries will ameliorate this kind of problem, but one doesn't bet a lot of money on it. Regards, John Levine, johnl@iecc.cambridge.ma.us, {spdcc|ima|world}!iecc!johnl