On Thu, Oct 31, 2002 at 11:22:27AM -0600, [EMAIL PROTECTED] wrote:
> The issue is - how to ensure your command is handled by the shell when 
> perl has disgression to avoid it if it feels like it. The answer is simple 
> - force the issue and execute it directly like system("cmd /c \"COPY foo 
> bar\""). That form will handle both cases where either CreateProcess() or 
> the shell can handle it.

You should submit a bug report about this, if this is true. When the
patch to 'optimize' system() and exec() was included into Perl, one of
the requirements was that the change would be transparent. You shouldn't
need to be aware that system() or exec() is being optimized.

The following command 'works' for me with ActiveState build 633:

    C:\> perl -e "system(qq(echo Hello World!)); print qq($?\n)"
    Hello World!
    0

The following command also 'works' for me with ActiveState build 633:

    C:\> perl -e "system(qq(copy a.zip b.zip)); print qq($?\n)"
    0

b.zip is created and is the same length as a.zip. I didn't bother to
do a checksum.

The code in win32/win32.c says (Only AS 631 source handy, sorry...):

    status = win32_spawnvp(flag,
                           (const char*)(really ? SvPV_nolen(really) : argv[0]),       
                    (const char* const*)argv);

    if (status < 0 && (errno == ENOEXEC || errno == ENOENT)) {
        /* possible shell-builtin, invoke with shell */
        int sh_items;
        sh_items = w32_perlshell_items;
        while (--index >= 0)
            argv[index+sh_items] = argv[index];
        while (--sh_items >= 0)
            argv[sh_items] = w32_perlshell_vec[sh_items];

        status = win32_spawnvp(flag,
                               (const char*)(really ? SvPV_nolen(really) : argv[0]),
                               (const char* const*)argv);
    }

In other words - if the optimization fails with a status of < 0, and
the error code is ENOEXEC or ENOENT, we assume that the command may be
a built-in, and we execute it using cmd.exe/command.com.

mark

-- 
[EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED] __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Neighbourhood Coder
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | 
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
                       and in the darkness bind them...

                           http://mark.mielke.cc/

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to