Web lists-archives.com

Re: Run command in new window

On 12/26/2017 8:16 PM, Steven Penny wrote:
> On Tue, 26 Dec 2017 17:44:11, cyg Simple wrote:
>> 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\'
> continuing from my previous email [1], here is an example of your
> command in
> action:
>    $ z=1
>    $ cygstart bash -c \'echo $z\; read\'
> and here is something that breaks your example:
>    $ z=\'
>    $ cygstart bash -c \'echo $z\; read\'

Yes, it is going to break the bash -c command started by cygstart
because $z is expanded on the command line with cygstart.  So it becomes
equivalent to

$ bash -c 'echo '; read'

which will not work.  The follow combination is needed to echo a single
quote from bash.

$ bash -c "echo \'; read"

So to translate to cygstart

$ cygstart bash -c \"echo \\\'\; read\"
$ export z="'"
$ bash -c "echo \\${z}; read"
$ cygstart bash -c \"echo \\\\${z}\; read\"

> so you see, your command assumes that no single quotes will be between the
> single quotes, which is just not robust. it seems something like one of
> these

Quotes as well as variables need to be quoted.

> will be needed:
> - bash printf %q
> - coreutils printf %q
> - homebrew function [2]
> [1] http://cygwin.com/ml/cygwin/2017-12/msg00263.html
> [2] http://github.com/svnpenn/stdlib/blob/45df8cf/libstd.awk#L318-L326

Don't know.  I do know that

$ bash -c 'echo \'; read'

fails to work when I think it should as the \ should cause the '
following it to be ignored by the command line processor.

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