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

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.

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.

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:
Unsubscribe info:

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