Re: External process fails with switch arguments
- From: "Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx>
- Date: Mon, 25 Jun 2007 19:48:17 -0500
"Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx> wrote in message news:op.tuhqh2ar8jd0ej@xxxxxxxxxxxxxxxxxxxxxxx
On Mon, 25 Jun 2007 10:41:31 -0700, Ben Voigt [C++ MVP] <rbv@xxxxxxxxxxxxx> wrote:
Interestingly, for me "date.exe /t" gives the expected output. Is that
still running a cmd.exe builtin? If so, I'd classify that as a bug.
Well, then it's a bug that's been in the command line interpreter for ages. My recollection is that the DOS CLI has always treated any name followed by .exe or .com as the built-in command if no matching program is found. Maybe I'm wrong and this was new to DOS 2.0 (which introduced a lot of new features, relatively speaking). Hard to remember for sure, going that far back.
But that shouldn't imply that a different mechanism that doesn't go through the CLI should produce the same behavior. There's a big difference between using an interactive interpreter and simply telling the operating system to start a process. Any process must have some executable from which the process is started. The only reason that the CLI can map what looks like an executable file to a built-in command is that the CLI is already running and can intercept that. But when starting the process in the first place, there's no CLI running to do the mapping. So an actual executable is required.
By explicitly specifying that the CLI is run ("cmd.exe"), then a command can be passed to that CLI, and it's parsed just as it would have been had the user typed it at the command prompt. Of course, replacing "date" with "date.exe" in that case would result in the original behavior, assuming an alternative "date.exe" was still installed, and if not would produce the built-in "date" command.
[...]
Looks like not only is "date" a cmd.exe builtin, so is "date.exe"??? Looks
like a bug...
See above. The only reason that "date.exe" is a "built-in" is that it matches in name with an existing built-in, and this is either by design, or a very ancient, unnoticed, unresolved bug. If an actual date.exe had been found in the path, that would be run instead.
Seems like reasonable behavior for the DOS CLI to me. But if you feel it's a bug, I think you ought to report it to Microsoft. :)
Well, on every other shell I've ever used, if there is an alias for "date" and I type "date.sh" or "date.pl" or whatever, it doesn't match the alias.
If the "help" command (or is it help.exe?) listed the builting commands with the ".exe" extension then I would agree with the behavior. "date" alone would search for "date.com" and "date.exe" and find the builtin. And "date.exe" would match the builtin. But here I specified "date.exe" and the builtin is named "date" and I can't see that being a match.
Is this behavior for built-ins documented somewhere?
Pete
.
- Follow-Ups:
- Re: External process fails with switch arguments
- From: Peter Duniho
- Re: External process fails with switch arguments
- References:
- RE: External process fails with switch arguments
- From: Steven Cheng[MSFT]
- Re: External process fails with switch arguments
- From: Peter Duniho
- Re: External process fails with switch arguments
- From: Ben Voigt [C++ MVP]
- Re: External process fails with switch arguments
- From: Peter Duniho
- RE: External process fails with switch arguments
- Prev by Date: Datatable : ReadErrorLog
- Next by Date: Re: How can I tell my app where it's executed from?
- Previous by thread: Re: External process fails with switch arguments
- Next by thread: Re: External process fails with switch arguments
- Index(es):
Relevant Pages
|