in reply to Re: The Evil Embedded Space (system(@list))
in thread The Evil Embedded Space
The basic Microsoft C argument processing is that you put double quotes around anything to make it a single argument. Backslash is only special if it is followed by a double quote. So \ is just \ but \" becomes a literal " character, but this is only reliable if done within double quotes. So \\" becomes a backslash followed by a close-quote. \\\" becomes backslash followed by literal quote.
So you want something like:
for( @args ) { if( /[\s"^*?%<>|&]/ ) { s#(\\*)"#$1$1\\"#g; $_= '"' . $_ . '"'; } }
Perhaps with more special characters in the first match.
Update: Oops, I was missing one backslash in my replacement. I had $1$1" when I needed $1$1\\", and we should probably avoid adding quotes if the argument is already surrounded by quotes, at least by default.
- tye
|
---|