www.delorie.com/djgpp/faq/command-line/globbing.html   search  
Can I do filename globbing with djgpp?

I call my program with an argument x*y and it complains about something called ``xyzzy''??...

The filename globbing in djgpp is done by the go32 extender, before the program starts running. This is like under Unix, where the globbing is done by the command shell, only a bit different (see below). Unlike other DOS-based compilers, where if you want the program to glob its arguments you must link it with a special object module, in djgpp this is considered normal behavior and performed by default on behalf of every djgpp program. The x*y above was expanded to a file called xyzzy which was probably present in the current working directory.

In djgpp, filename globbing works like in Unix, which is more general than the usual DOS wildcard expansion. It understands the following constructs with special meta-characters:

? - any single character
* - zero or more arbitrary characters, including a dot `.'
[aA_] - any one of characters `a', `A', or `_'.
[a-d] - any one of characters `a', `b', `c', or `d'.
[!a-z] - anything BUT a lowercase letter.

Unlike DOS, the * and ? meta-characters can appear anywhere in the filename pattern, like in [a-z]*[0-9].*pp. You can also use * instead directories, like in */*/*.c, but NOT on drive letters (e.g., [a-c]:/ won't work).

An argument which cannot be expanded (no filenames matching that particular pattern) will be passed to the program verbatim. This is different from what you'd see under Unix, where the shell would say something like ``No match'' and won't call your program at all.

  next     webmaster   donations   bookstore     delorie software   privacy  
  Copyright 1995   by DJ Delorie     Updated Feb 1995