Web lists-archives.com

Re: Run command in new window




> and for some reason any spaces must be quoted - not escaped - these work:
>
>    cygstart bash -c '"echo 1;read"'
>    cygstart bash -c "'echo 1;read'"
>
> these fail:
>
>    cygstart bash -c 'echo\ 1;read'
>    cygstart bash -c "echo\ 1;read"


The '-v' option to cygstart gives the key to understanding this by
showing what actually gets passed along by cygstart.
WORKS:
davec@SodiumWin ~
$ cygstart -v bash -c " ' echo  TT; sleep 5 ' "
ShellExecute(NULL, "(null)", "bash", "-c  ' echo  TT; sleep 5 ' ", "(null)", 1)
The quotes surrounding the argument to -c get passed along to the executed bash.

WORKS:
davec@SodiumWin ~
$  cygstart -v bash -c '"echo 1;read"'
ShellExecute(NULL, "(null)", "bash", "-c "echo 1;read"", "(null)", 1)
Same here, the echo and read are both contained in one argument to -c.

DOES NOT WORK
davec@SodiumWin ~
$ cygstart -v bash -c 'echo\ 1;read'
ShellExecute(NULL, "(null)", "bash", "-c echo\ 1;read", "(null)", 1)
Without the quotes to group the echo and read together, when the
executed bash breaks the line up into words, the -c only sees echo\ as
its command.

WORKS:
davec@SodiumWin ~
$ 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.

Does this help at all?

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