Date: Tue, 27 Oct 1998 19:37:45 +0100 From: Hans-Bernhard Broeker Message-Id: <199810271837.TAA25985@acp3bf.physik.rwth-aachen.de> To: gfenwick AT primex DOT co DOT uk (Graeme Fenwick) Cc: djgpp AT delorie DOT com Subject: Re: /? command line args being altered by DJGPP Newsgroups: comp.os.msdos.djgpp Organization: RWTH Aachen, III. physikalisches Institut B X-Newsreader: TIN [version 1.2 PL2] Reply-To: djgpp AT delorie DOT com In article <3635f355 DOT 0 AT scooby DOT nildram DOT co DOT uk> you wrote: > Hi all! > At first I thought this was 99% certain to be a DOS issue. In a sense, it is. More precisely, it's a DJGPP issue, which happens when DJGPP tries to get around one of the many differences between DOS and Unix. > Put simply, I've written (part of a) program to parse command line > arguments, and it's running into trouble when I try to read the arguments > "/?", "/??", "/???" and so on. On Unix, and thus also in DJGPP programs, '/' is not the typical character that starts a command line option. It's the directory separator, instead (what DOS uses '\' for). In comes another Unixism: the shell filenaming globbing. Generally, if you give a filename like a?b* on a Unix shell command line, it will not be passed to the child program. Instead, the shell will try to find all filenames matching this pattern, and pass the full list of filenames found to the child. I.e. if you type ls bla* the actual command line used to call 'ls' might be: ls blafasel blabbla blaff.c Only if no matching filenames are found, the pattern (including ? and *) will be passed to the subprogram, instead. Now, command.com doesn't behave like this, obviously. It always passes the unchanged command line to the called program, leaving it to the child to 'glob' the filenames, if needed. But DJGPP tries to be as Unixy as possible, so every DJGPP program (unless told otherwise) will do this globbing itself, so the effective command line you see (in argv[] argument of main(), e.g.) will have been expanded, if possible. > "test /?" gives the output "/a" You do have a directory /a in the root of your DJGPP drive, right? > "test /??" gives the output "/??" (correct, this time) But no directory with a two-letter directory name. > "test /???" gives the output "/ati" ... and there's a directory c:\ati. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.