Date: Wed, 19 Feb 1997 11:23:10 +0200 (IST) From: Eli Zaretskii To: "Vyacheslav O. Myskin" cc: djgpp AT delorie DOT com Subject: Re: Starnge rm behavour In-Reply-To: <19B60DC0919@csd.inp.nsk.su> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 19 Feb 1997, Vyacheslav O. Myskin wrote: > Sorry, but I don't understand... No wonder: it's tricky... > Or does rm refuse to expand '*' only because it knows that it was > passed via spawnXX (can't see any sense)? This is correct. Since DJGPP programs pass arguments in a special way, they can tell when they were invoked by `spawnXX'; in that case, the startup code doesn't expand the wildcards. The reason is POSIX compatibility. POSIX specifically requests that arguments passed by `execXX' family of functions aren't expanded by a shell (which is where the wildcards are expanded on Unix), but are passed to the child verbatim. Beginning with v2.01, DJGPP complies. > So if rm sees an asterisk as an argument, why doesn't > it process it in a proper way (that means search for all files in a directory > and delete them)? Neither `rm' nor most other programs have any wildcard expansion functions in their code (called by `main'). On Unix, the wildcard expansion is done by the shell; in DJGPP it is done by the startup code (see chapter 16 in the DJGPP FAQ list for more details) before `main' is called. This expansion is disabled when `rm' is called by `spawnXX'. > But it makes impossible to use rm -f somedir/* in makefiles, which is > much worse. No, the above command will work perfectly in a Makefile, because Make calls `system' when it sees a wildcard (or any other character special to the shell). Btw, that is exactly how Make works on Unix: when it sees a wildcard, it calls the shell to do the job instead of calling `execXX'. (In general, you should try things before complaining that they don't work.)