Web lists-archives.com

Re: Run command in new window




On 12/26/2017 2:41 PM, Steven Penny wrote:
> On Tue, 26 Dec 2017 11:54:14, Dave Caswell wrote:
>> $ cygstart -v bash -c \'echo 1\;read \'
>> ShellExecute(NULL, "(null)", "bash", "-c 'echo 1;read '", "(null)", 1)
>> By escaping the quotes and semicolon so they get passed along intact,
>> the executed bash also gets an intact command string.
> 
> this is interesting, but it doesnt explain (or im not understanding) why
> it will
> accept a quoted string and not an escaped one. in a normal setting, these
> commands are identical:
> 
>    $ bash -c 'echo; read'
>    + bash -c 'echo; read'
> 
>    $ bash -c echo\;\ read
>    + bash -c 'echo; read'
> 
> but with cygstart this command works:
> 
>    cygstart bash -c '"echo; read"'
> 
> and this does not:
> 
>    cygstart bash -c 'echo\;\ read'

As I said earlier the quotes are interpreted by the shell executing the
command.  So the shell execing the cygstart command is not passing the
quote to the secondary bash session because it has interpreted them.  If
you want to pass quotes to the process on the command line then you need
to quote them or use a backslash on the quote to prevent the shell doing
the exec to process them.

$ cygstart bash -c \'echo 1\; read\'

-- 
cyg Simple

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