Re: External process fails with switch arguments

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"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

.



Relevant Pages

  • Re: External process fails with switch arguments
    ... 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. ... 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. ...
    (microsoft.public.dotnet.languages.csharp)
  • Wolfpack 4.3.10 Server Release
    ... Plug file descriptor leak in add command. ... This feature was flawed (it encourages players to ... Redesign of synchronization between commands, update and shutdown, ... The bug allowed players to delay ...
    (rec.games.empire)
  • Why newbies dont RTFM...
    ... Even though I've used Linux before, I've never had to do any ... BASH BUILTIN COMMANDS ... last command exited within ... unless the shell is not exeâ ...
    (comp.os.linux.misc)
  • coreutils-8.1 released [stable]
    ... run a command like this: ... If that command fails because you don't have the required public key, ... [bug introduced in coreutils-8.0] ... read-to-EOF and the inotify watch initialization would be ignored ...
    (gnu.announce)
  • Re: Great SWT Program
    ... a good tutorial on Unix CLI tools? ... command there, ... then rename everything in the search scope with the CLI, ... I'd have to boot up a Windows system and try stuff, ...
    (comp.lang.java.programmer)