This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Formatting command line arguments when starting a Cygwin process from a native process


On Thu, May 5, 2016 at 11:24 AM, David Allsopp wrote:
>
> I am trying to work out the precise details for character escaping when
> starting a Cygwin process from a native (i.e. non-Cygwin) Windows process.
<snip>
> For example:
>
>   argv[0] = "foo"
>   argv[1] = "bar baz"
>
> then the resulting command line string should be:
>
>   lpCommandLine = "foo bar\" \"baz"

If I recall correctly, Windows cmd.exe uses the carrot (^) as the
general escape from shell character, so

C:\cygwin64\bin>.\echo.exe -e ^"hello\nworld^"
hello
world

works.

However, I've found Windows's interpretation to be inconsistent, so
often have to play with it to find what the "right combination" is for
a particular instance.

I find echoing the parameters to a temporary text file and then using
the file as input to be more reliable and easier to troubleshoot, and
it breaks apart whether it is Windows cli inconsistencies or receiving
program issues very nicely with the text file content as an
intermediary

-- Erik

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]