Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: (Windows) verbatim command line arguments inside Perl script

by BillKSmith (Monsignor)
on Apr 16, 2021 at 15:19 UTC ( #11131386=note: print w/replies, xml ) Need Help??

in reply to (Windows) verbatim command line arguments inside Perl script

Not exactly what you want, but note that windows does allow you to escape quotes.
>perl -E"say qq(@ARGV)" "\"1 2\" \"3\" 4" "1 2" "3" 4

Replies are listed 'Best First'.
Re^2: (Windows) verbatim command line arguments inside Perl script
by LanX (Sage) on Apr 16, 2021 at 15:45 UTC
    cmd.exe is also allowing unclosed quotes, with is frankly a PITA

    D:\tmp\exp>perl -E"say join'|',@ARGV" "1\" 2" "3 1" 2|3

    And I already noticed that the escaped quotes are killing my workaround

    D:\tmp\exp>type cmd_wrapper.bat @echo off echo %*| perl.exe .\ D:\tmp\exp>cmd_wrapper.bat "1\" 2" "1\" 2"| perl.exe .\

    what seems to happen is that

    1. %* is expanded like a macro before executing the bat
    2. The second quote is not considered escaped for echo
    3. The pipe is seen as part of an unclosed "string"
    4. hence the call to perl.exe is echo'ed like a string and never executed

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2022-05-29 09:23 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (101 votes). Check out past polls.