|Keep It Simple, Stupid|
(Windows) verbatim command line arguments inside Perl scriptby LanX (Cardinal)
|on Apr 16, 2021 at 12:37 UTC||Need Help??|
LanX has asked for the wisdom of the Perl Monks concerning the following question:
I need to write a Perl script which is generating a .bat-file while passing it's command line arguments 1-to-1
Is there any way to access the "raw" command-line in order to catch quoting and escaping?
To highlight the problem:
As you can see are all quotes and escapes lost while calling Perl (for good reasons)
But my script has to generate another .bat which does
Typical edge-case justifying this problem are win-paths with whitespace, but cmd.exe has also some arcane escaping rules.
I already have a workaround:
I discovered that .bat has %* to hold the verbatim command line arguments, and came up with a workaround of a .bat calling my perl-script
Question: any better solution?
PS: I don't think this question is overly Win specific, when creating a bash script on Linux I'd face the same problem.