You are mixing command line parsing in command.com / cmd.exe and the Windows-APIs.

Unlike in Unix, command line parsing is the job of the invoked program (and not that of the shell) on Windows, this typically happens in the C RTL. The command interpreters themself also parse their input, but only to find the executable or build-in command and to handle redirections. The build-in commands (dir, cd, ...) must also parse their argument string, probably using the same or very similar routines.

After that parsing has happened, quotes and escape characters are gone, and the program or build-in command has a list of (unescaped) arguments, some of them are passed to API functions. The API functions do not remove quotes:

X:\>dir 979536.exe Volume in drive X is RAMDISK Volume Serial Number is 065B-0000 Directory of X:\ 05.07.2012 22:04 121.535 979536.exe 1 File(s) 121.535 bytes 0 Dir(s) 129.867.776 bytes free X:\>dir "979536.exe" Volume in drive X is RAMDISK Volume Serial Number is 065B-0000 Directory of X:\ 05.07.2012 22:04 121.535 979536.exe 1 File(s) 121.535 bytes 0 Dir(s) 129.867.776 bytes free X:\>perl -Mautodie -e "open $f,'979536.exe'" X:\>perl -Mautodie -e "open $f,chr(34).'979536.exe'.chr(34)" Can't open($fh, '"979536.exe"'): Invalid argument at -e line 1 X:\>type openfail.c #include <stdio.h> #include <errno.h> int main(int argc, char ** argv) { FILE * f; if ((f=fopen("979536.exe","r"))==NULL) { perror("open without quotes"); } else { fclose(f); } if ((f=fopen("\"979536.exe\"","r"))==NULL) { perror("open with quotes"); } else { fclose(f); } return 0; } X:\>gcc -Wall -pedantic -o openfail.exe openfail.c X:\>.\openfail.exe open with quotes: Invalid argument X:\>

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^5: true from (-e "") on Windoze (" is an illegal filename character by afoken
in thread true from (-e "") on Windoze by CarolinaPerler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.