X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; q=dns; s=default; b=jP jzcabYh2JSabfso7JHr1r7IJ58uOvXtB/fWbUoLf+Pc7kq6VeCdpQGX8/Y630ixs RTKfI3GvXlzOwuXC6n2UmBmXdvewtXGRjlmaPuKd7UUnnof1GKOI0A+GLAsrkqsB 5uSJOglq7Uq77MBGn9o6foa25fDSmgLKp5hOP6Mn8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; s=default; bh=xoAeRnBv 5WXtgFr+0be3nfl9Q8g=; b=KQ0Xarj5B0l0LHuvMY5xRorLdps0ffy1+yQ2BlJu Iu6vyd46rz42mAn2aFM48QCHFVHYx+HXQHn7/V8iaQW9qtL8BfkL4UUTvzHM+QK/ FIZR+lWWNNbeye7Cf7l73El2/BbOFgvdw8wn3aIAwTU1Jql2bDGKd2pHjsw7Hcjg E1E= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.4 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=lpcommandline, non-cygwin, noncygwin, nonCygwin X-HELO: mail-lf0-f49.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to; bh=hkL+C57kDgGMukbuhO/vZBrmCXntFQyHrbWh9Mza+4M=; b=lAOzl/UNIfpFty/0xihRlnuXrWZXljJlvtb8+odV2rU/xwGYej0Cg6cjJ44LvM11we PX2d6EiZdF585eMJGQdUgpNCf8trhxbbAs017uxqnU0WNN1yfrn0JDeQTGbJgGcKFI/p z6Dq4HRp1bZXNW9gYNFxr7FaPERwnrfJVkkVJfu8M06ON6+0iNO6WN+Iz3DNQv5QU3WA oyTxe44Pw/lrAOJP58zpQI849jZpR85Wa8W8QeBVL6qf1t1DA8XtiOGuVmqa2Jt7tako lwYfFD5mjCw3mfitWsE0y8eppCRqyyrN/X1ZqbHkr5g+jiUOvJAmlcNFbuzglGQGBYQF BRkg== X-Gm-Message-State: AOPr4FXcct/jJ0Qw3M4zxhkmyeXNGtt9t4D4fc+Y2AFzJkPKnPf5yRvm1UNCtEkpNPy1xUs8MPDwxMkrG1Jg5g== MIME-Version: 1.0 X-Received: by 10.25.89.77 with SMTP id n74mr6443778lfb.29.1462466827145; Thu, 05 May 2016 09:47:07 -0700 (PDT) In-Reply-To: <005c01d1a6e2$30270ba0$907522e0$@metastack.com> References: <005c01d1a6e2$30270ba0$907522e0$@metastack.com> Date: Thu, 5 May 2016 12:47:07 -0400 Message-ID: Subject: Re: Formatting command line arguments when starting a Cygwin process from a native process From: Erik Soderquist To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes 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. > 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