Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^4: Construct command portable way

by Corion (Patriarch)
on May 07, 2009 at 07:26 UTC ( [id://762508]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Construct command portable way
in thread Construct command portable way

system(LIST) avoids cmd.exe on Win32 already, if possible, just like it avoids the shell under unixish systems. Unfortunately, a common mechanism for parsing the command line has found its way into Windows only as CommandLineToArgvW, but as I see now, it shouldn't be hard to use this "standard" way of parsing the command line everywhere except Win 9x (which I still consider a loss for Perl).

Replies are listed 'Best First'.
Re^5: Construct command portable way
by afoken (Chancellor) on May 07, 2009 at 09:12 UTC
    it shouldn't be hard to use this "standard" way of parsing the command line everywhere except Win 9x

    It would "just" require all existing programs to drop whatever command line parsing they use and use CommandLineToArgvW instead, converting the command line to Unicode and the returned elements back from Unicode in non-Unicode applications.

    Windows argument passing simply sucks. Each program can and has to implement its own parsing routine. Most programs rely on the runtime library to handle the parsing. For them, we "only" have to handle the different parsers of the various runtime libraries (all Borland DOS and Windows compilers/RTLs ever released, all Microsoft DOS and Windows compilers/RTLs ever released, and all those special compilers/RTLs like DJGPP, Phar Laps, 4GW, MinGW, ...). Other programs may use Windows API functions like CommandLineToArgvW. For the remaining programs that implement their own parsing routine, we are simply lost. There is no standard for quoting or parsing.

    A rather drastical approach would be to limit system(LIST) to a list of exactly one or two arguments, where the second argument would be the entire command line passed to the program via CreateProcess() or similar functions. This represents the underlying API quite well, but it would break nearly all perl code that uses system(LIST).

    Alexander

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://762508]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2024-03-29 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found