> cmd.exe does perform some substitutions,
If you are referring to %variables% , that's fine.
I only need to be able to reproduce the exact call inside a Perl wrapper.
| [reply] [d/l] |
In that case, using GetCommandLine as haukex suggested will work for the common case. I do not know enough about cmd.exe quoting to say what will happen with "odd" inputs, but I vaguely remember reading an explanation of Windows shell quoting somewhere that mentioned that ^ was somehow special, but not removed and therefore not useful as a quote character. I got the impression that there are no predictable rules in Windows shell quoting.
The main problem I foresee in edge cases is the possibility that cmd.exe will further interpret your command tail if given a chance to read it again, as will occur if you write it out in a batch file. For example, as I recall, double quotes are quoted within double-quoted text by doubling them: "foo""bar" is passed as foo"bar. Now consider saving the command tail if "foo""""bar" is given, which will arrive as foo""bar and be reduced to foobar if cmd.exe gets to read it again and I understand correctly. Perhaps it is the C runtime startup code that actually does quote removal, in which case the command tail as returned from GetCommandLine will still have the original quotes.
Could there be another way to solve this? If you just need to rerun your script with the same @ARGV, could you serialize @ARGV somehow (Storable, YAML, JSON, ...) and have a --recover-arguments FILE option that just reads the file and overwrites @ARGV?
| [reply] [d/l] [select] |