www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/05/09/11:50:07

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:from:to:references:in-reply-to:subject:date
:message-id:mime-version:content-type:content-transfer-encoding;
q=dns; s=default; b=lj8FHX8FlaDHRiJHOXgEwsj7Or7eIiEHSgebMd1nAAc
VLpk+qLbkDchY6R1EQ65dIyB7l4xws9qfR1Ef5croTGgQc3azLyVe4BlYSHwxVs8
uiOyLWGf1bdm5EfVrtKuUG/5VRauwTxlLxinoNb3C+ScbB+oJoWqNyenZnN8uTpE
=
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:from:to:references:in-reply-to:subject:date
:message-id:mime-version:content-type:content-transfer-encoding;
s=default; bh=rdzwsOf5MVu1USQ73bU2XLZvzBA=; b=N/K3c0cnPxDKW9rC1
9UjyoWM3wqgdf3VvPzYPOSt6huKBiwCMvJgrs/02pzAKRoqcXx2ycl+xgRTpSQcK
yjeiOG0yTqU5kkF609YHSHqEa/JGEpCxeNjbfX9gZNa9xup0mH6tu+R6cdwEdp/n
KzfLYqniIvQMFmoN5f6u0QdMKc=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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.9 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL autolearn=ham version=3.3.2 spammy=D*o, callee.exe, fo AT o, commandLine
X-HELO: outmail149082.authsmtp.co.uk
From: "David Allsopp" <dra27 AT cantab DOT net>
To: "'Peter Rosin'" <peda AT lysator DOT liu DOT se>, <cygwin AT cygwin DOT com>
References: <005c01d1a6e2$30270ba0$907522e0$@metastack.com> <CACoZoo1LObZ0zu9X5O6dV4cO4jN+GO28bdRbuDkTMdaKHXpVbQ AT mail DOT gmail DOT com> <000101d1a76d$c37c6b80$4a754280$@metastack.com> <967954968 DOT 20160506172040 AT yandex DOT ru> <006301d1a834$6ccd1380$46673a80$@cantab.net> <6e1f2ba2-0c8e-4659-4c5a-d748e90c1ced AT lysator DOT liu DOT se>
In-Reply-To: <6e1f2ba2-0c8e-4659-4c5a-d748e90c1ced@lysator.liu.se>
Subject: RE: Formatting command line arguments when starting a Cygwin process from a native process
Date: Mon, 9 May 2016 16:49:42 +0100
Message-ID: <008e01d1aa0a$67a9ef40$36fdcdc0$@cantab.net>
MIME-Version: 1.0
X-Server-Quench: a6825b07-15fd-11e6-829e-00151795d556
X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse
X-AuthRoute: OCd1ZAARAlZZVg1A VQsPBSlcQA9jIBBQ FxoeKRdbOF4EFV4Q JB4LaX9aIRpGHQgH E2cNUVBdWll1F2F0 aBRQbQBDYEtMQQRr VFdLR01TWkBsCGpf XkZBUhFxdQxDNntw bEQsD3ZTXkEodUFg Q0sCQXAHZDJmdWgd WRVFdwNVdQJNdxoR b1V5GhF4a3VxOTg9 FhMvPjY+dT5YLSFc RA1FKVMUTA4CBDEh Qh0EAS5nAk0IQW0o MxU8Nl8aEw4Yem4j PkQgXxoAKRgZBxZF V09XByoRLhEHTjYq Ew4SRVQZGzBGWk9e
X-Authentic-SMTP: 61633634383431.1037:706
X-AuthFastPath: 0 (Was 255)
X-AuthSMTP-Origin: 213.105.212.114/25
X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system.
X-IsSubscribed: yes

Hi!

Peter Rosin wrote:
> I think cygwin emulates posix shell style command line parsing when
> invoked from a Win32 process (like you do). So, try single quotes:
> 
> commandLine = "callee.exe \"@\"te\"\n\"st fo AT o bar\" \"baz baz '*'
> '\"\\'\"'";
> 
> I get this (w/o noglob):
> 
> argc = 7
> argv[0] = callee
> argv[1] = @te
> st
> argv[2] = fo AT o
> argv[3] = bar baz
> argv[4] = baz
> argv[5] = *
> argv[6] = "'"

Yes, that seems to be approximately the way I arrived at too - my concern
with all the extra quoting is then hitting the Windows limit on command line
length (I'd like to avoid needing @response files as much as possible). So
with various experimenting, the slightly odd scheme I've come up with is
that if none of the arguments contain double-quote characters, then set
noglob and use the quoting mechanism previously described (so whitespace
within an argument or an @ at the beginning of an argument needing
double-quoting) and if a double-quote character appears in any of the
arguments, then don't set noglob and escape every argument with
double-quotes (to avoid globbing) - any double-quote characters within can
then be escaped with "'"'" (i.e. terminate the current quote string,
single-quote a double-quote and then resume a quote string!). Messy, but
that seems to be about the only way...


David 


--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019