public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Run command in new window
@ 2017-12-25  3:50 Steven Penny
  2017-12-25  4:06 ` Andrey Repin
  0 siblings, 1 reply; 18+ messages in thread
From: Steven Penny @ 2017-12-25  3:50 UTC (permalink / raw)
  To: cygwin

I can run a command line this as expected:

    cygstart sleep 5

However a command like this is a problem:

    cygstart echo hello

a new window is open, and the command is run, but the window immediately closes,
so you do not get to see the output. How can this be resolved?


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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-25  3:50 Run command in new window Steven Penny
@ 2017-12-25  4:06 ` Andrey Repin
  2017-12-25  4:37   ` Steven Penny
  0 siblings, 1 reply; 18+ messages in thread
From: Andrey Repin @ 2017-12-25  4:06 UTC (permalink / raw)
  To: Steven Penny, cygwin

Greetings, Steven Penny!

> I can run a command line this as expected:

>     cygstart sleep 5

> However a command like this is a problem:

>     cygstart echo hello

> a new window is open, and the command is run, but the window immediately closes,
> so you do not get to see the output. How can this be resolved?

The usual way - prevent the closing of the new window.
I.e. by adding a sleep.


-- 
With best regards,
Andrey Repin
Monday, December 25, 2017 06:28:12

Sorry for my terrible english...


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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-25  4:06 ` Andrey Repin
@ 2017-12-25  4:37   ` Steven Penny
  2017-12-25  4:54     ` Dave Caswell
  0 siblings, 1 reply; 18+ messages in thread
From: Steven Penny @ 2017-12-25  4:37 UTC (permalink / raw)
  To: cygwin

On Mon, 25 Dec 2017 06:28:50, Andrey Repin wrote:
> The usual way - prevent the closing of the new window.
> I.e. by adding a sleep.

no, that doesnt work

have you tried it?

if so provide sample command


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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-25  4:37   ` Steven Penny
@ 2017-12-25  4:54     ` Dave Caswell
  2017-12-25  5:11       ` Steven Penny
  0 siblings, 1 reply; 18+ messages in thread
From: Dave Caswell @ 2017-12-25  4:54 UTC (permalink / raw)
  To: cygwin

On Sun, Dec 24, 2017 at 8:50 PM, Steven Penny <svnpenn@gmail.com> wrote:
> On Mon, 25 Dec 2017 06:28:50, Andrey Repin wrote:
>>
>> The usual way - prevent the closing of the new window.
>> I.e. by adding a sleep.
>
>
> no, that doesnt work
>
> have you tried it?
>
> if so provide sample command

Here's an example:

davec@SodiumWin ~
$ cygstart bash -e TT

davec@SodiumWin ~
$ cat TT
#! /usr/bin/bash

echo TEST
sleep 240

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-25  4:54     ` Dave Caswell
@ 2017-12-25  5:11       ` Steven Penny
  2017-12-26 17:43         ` Dave Caswell
  0 siblings, 1 reply; 18+ messages in thread
From: Steven Penny @ 2017-12-25  5:11 UTC (permalink / raw)
  To: cygwin

On Sun, 24 Dec 2017 21:06:05, Dave Caswell wrote:
> Here's an example:
> 
> davec@SodiumWin ~
> $ cygstart bash -e TT
> 
> davec@SodiumWin ~
> $ cat TT
> #! /usr/bin/bash
> 
> echo TEST
> sleep 240

yes, that is good if you want to use a script - but a command does not work:

    cygstart bash -c 'echo hello; sleep 5'


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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-25  5:11       ` Steven Penny
@ 2017-12-26 17:43         ` Dave Caswell
  2017-12-26 18:54           ` Steven Penny
  0 siblings, 1 reply; 18+ messages in thread
From: Dave Caswell @ 2017-12-26 17:43 UTC (permalink / raw)
  To: cygwin

On Sun, Dec 24, 2017 at 9:34 PM, Steven Penny <svnpenn@gmail.com> wrote:
>
> yes, that is good if you want to use a script - but a command does not work:
>
>    cygstart bash -c 'echo hello; sleep 5'
>
Ah, OK.  Here you go:

davec@SodiumWin ~
$ cygstart /usr/bin/bash '-c "echo hello; sleep 5"'

I wish I could explain just why this quotation pattern works here.  A
long time ago I found that dicking around with the quotes could often
get things working faster than trying to understand it in detail.

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-26 17:43         ` Dave Caswell
@ 2017-12-26 18:54           ` Steven Penny
  2017-12-26 19:12             ` Steven Penny
  0 siblings, 1 reply; 18+ messages in thread
From: Steven Penny @ 2017-12-26 18:54 UTC (permalink / raw)
  To: cygwin

On Sun, 24 Dec 2017 21:53:19, Dave Caswell wrote:
> Ah, OK.  Here you go:
> 
> davec@SodiumWin ~
> $ cygstart /usr/bin/bash '-c "echo hello; sleep 5"'
> 
> I wish I could explain just why this quotation pattern works here.  A
> long time ago I found that dicking around with the quotes could often
> get things working faster than trying to understand it in detail.

that did it - thanks - this also works:

    cygstart bash '-c "echo hello; read z"'

seems like a problem with cygstart parser? here is the syntax:

    cygstart [OPTION]... FILE [ARGUMENTS]

so should support multiple arguments - this command works as expected

    cygstart touch 1 2 3

maybe the hyphen in "-c" is causing the problem?


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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-26 18:54           ` Steven Penny
@ 2017-12-26 19:12             ` Steven Penny
  2017-12-26 19:41               ` Dave Caswell
  2017-12-26 22:44               ` cyg Simple
  0 siblings, 2 replies; 18+ messages in thread
From: Steven Penny @ 2017-12-26 19:12 UTC (permalink / raw)
  To: cygwin

On Sun, 24 Dec 2017 21:08:17, Steven Penny wrote:
> that did it - thanks - this also works:
> 
>     cygstart bash '-c "echo hello; read z"'
> 
> seems like a problem with cygstart parser? here is the syntax:
> 
>     cygstart [OPTION]... FILE [ARGUMENTS]
> 
> so should support multiple arguments - this command works as expected
> 
>     cygstart touch 1 2 3
> 
> maybe the hyphen in "-c" is causing the problem?

update - cygstart does support multiple arguments, but any spaces will cause a
problem. for example this command works fine:

    cygstart bash -c 'echo;read'

but this fails

    cygstart bash -c 'echo 1;read'

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"


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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-26 19:12             ` Steven Penny
@ 2017-12-26 19:41               ` Dave Caswell
  2017-12-26 23:44                 ` Steven Penny
  2017-12-26 22:44               ` cyg Simple
  1 sibling, 1 reply; 18+ messages in thread
From: Dave Caswell @ 2017-12-26 19:41 UTC (permalink / raw)
  To: cygwin

> 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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-26 19:12             ` Steven Penny
  2017-12-26 19:41               ` Dave Caswell
@ 2017-12-26 22:44               ` cyg Simple
  1 sibling, 0 replies; 18+ messages in thread
From: cyg Simple @ 2017-12-26 22:44 UTC (permalink / raw)
  To: cygwin

On 12/26/2017 12:43 PM, Steven Penny wrote:
> On Sun, 24 Dec 2017 21:08:17, Steven Penny wrote:
>> that did it - thanks - this also works:
>>
>>     cygstart bash '-c "echo hello; read z"'
>>
>> seems like a problem with cygstart parser? here is the syntax:
>>
>>     cygstart [OPTION]... FILE [ARGUMENTS]
>>
>> so should support multiple arguments - this command works as expected
>>
>>     cygstart touch 1 2 3
>>
>> maybe the hyphen in "-c" is causing the problem?
> 
> update - cygstart does support multiple arguments, but any spaces will
> cause a
> problem. for example this command works fine:
> 
>    cygstart bash -c 'echo;read'
> 
> but this fails
> 
>    cygstart bash -c 'echo 1;read'
> 
> 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"


This has to do with the where the interpretation of the quote marks are
read.  The -c option for bash expects a quoted command but the quotes
are being interpreted by the parent shell executing the cygstart
command.  The quotes are not interpreted by cygstart itself.

$ 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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-26 19:41               ` Dave Caswell
@ 2017-12-26 23:44                 ` Steven Penny
  2017-12-27  1:11                   ` cyg Simple
  0 siblings, 1 reply; 18+ messages in thread
From: Steven Penny @ 2017-12-26 23:44 UTC (permalink / raw)
  To: cygwin

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'


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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-26 23:44                 ` Steven Penny
@ 2017-12-27  1:11                   ` cyg Simple
  2017-12-27  1:16                     ` Steven Penny
  2017-12-27  9:39                     ` Steven Penny
  0 siblings, 2 replies; 18+ messages in thread
From: cyg Simple @ 2017-12-27  1:11 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-27  1:11                   ` cyg Simple
@ 2017-12-27  1:16                     ` Steven Penny
  2017-12-27  1:38                       ` Jürgen Wagner
  2017-12-27  9:39                     ` Steven Penny
  1 sibling, 1 reply; 18+ messages in thread
From: Steven Penny @ 2017-12-27  1:16 UTC (permalink / raw)
  To: cygwin

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

I dont want to pass quotes. Sure, in this case it seems like the way to go, but
sometimes it might make sense to just escape the problem character(s) rather
than twice quote the whole thing.

If thats not possible then fine, but I havent seen someone say that its not
possible yet, and if so why its not possible.


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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-27  1:16                     ` Steven Penny
@ 2017-12-27  1:38                       ` Jürgen Wagner
  2017-12-27 22:46                         ` Steven Penny
  0 siblings, 1 reply; 18+ messages in thread
From: Jürgen Wagner @ 2017-12-27  1:38 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1144 bytes --]

Why don't you put the stuff to execute into a nice shell script and get
rid of the intricacies of quoting on the command line level?
That'a way easier to manage and test.

--j.

On 27.12.2017 00:44, 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\'
>
> I dont want to pass quotes. Sure, in this case it seems like the way
> to go, but
> sometimes it might make sense to just escape the problem character(s)
> rather
> than twice quote the whole thing.
>
> If thats not possible then fine, but I havent seen someone say that
> its not
> possible yet, and if so why its not possible.
>
>
> -- 
> 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
>
>



[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 3986 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-27  1:11                   ` cyg Simple
  2017-12-27  1:16                     ` Steven Penny
@ 2017-12-27  9:39                     ` Steven Penny
  2017-12-28 12:07                       ` cyg Simple
  1 sibling, 1 reply; 18+ messages in thread
From: Steven Penny @ 2017-12-27  9:39 UTC (permalink / raw)
  To: cygwin

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

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


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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-27  1:38                       ` Jürgen Wagner
@ 2017-12-27 22:46                         ` Steven Penny
  0 siblings, 0 replies; 18+ messages in thread
From: Steven Penny @ 2017-12-27 22:46 UTC (permalink / raw)
  To: cygwin

On Wed, 27 Dec 2017 02:11:52, Jürgen Wagner wrote:
> Why don't you put the stuff to execute into a nice shell script and get
> rid of the intricacies of quoting on the command line level?
> That'a way easier to manage and test.

really that seems like the best option. the only drawback to that is you wouldnt
be able to pass parameters to the script, else you run right back into the
previous problem:

    $ cat hw.sh
    printf '%s\n' "$@"
    read

    $ z='hello world'
    $ cygstart bash hw.sh "$z"
    hello
    world

so then you try to fix it with quoting:

    $ cygstart bash hw.sh "'$z'"
    hello world

which works until you get a variable with single quote:

    $ z=\'
    $ cygstart bash hw.sh "'$z'"
    # nothing

so you would either need a robust quoting solution [1], or need to create
temporary scripts for each invocation needed. not ideal either way

[1] http://cygwin.com/ml/cygwin/2017-12/msg00265.html


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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-27  9:39                     ` Steven Penny
@ 2017-12-28 12:07                       ` cyg Simple
  2017-12-28 20:11                         ` Steven Penny
  0 siblings, 1 reply; 18+ messages in thread
From: cyg Simple @ 2017-12-28 12:07 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Run command in new window
  2017-12-28 12:07                       ` cyg Simple
@ 2017-12-28 20:11                         ` Steven Penny
  0 siblings, 0 replies; 18+ messages in thread
From: Steven Penny @ 2017-12-28 20:11 UTC (permalink / raw)
  To: cygwin

On Wed, 27 Dec 2017 17:46:37, cyg Simple wrote:
> $ cygstart bash -c \"echo \\\'\; read\"
> $ export z="'"
> $ bash -c "echo \\${z}; read"

works

> $ cygstart bash -c \"echo \\\\${z}\; read\"

this assumes that "z" is something, if you do "z=" then it breaks

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

na, you can never single quote a single quote, it is not possible. you have to
split the string on each single quote, assuming the string has any - then you
single quote the substrings as needed and escape the single delimiting quotes:

    $ echo "hello ' world"
    + echo 'hello '\'' world'

it gets more complicated with cygstart because an extra layer of
quoting/escaping is added - I about have a function to automate it - hopefully
will post soon


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

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-12-28  0:03 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-25  3:50 Run command in new window Steven Penny
2017-12-25  4:06 ` Andrey Repin
2017-12-25  4:37   ` Steven Penny
2017-12-25  4:54     ` Dave Caswell
2017-12-25  5:11       ` Steven Penny
2017-12-26 17:43         ` Dave Caswell
2017-12-26 18:54           ` Steven Penny
2017-12-26 19:12             ` Steven Penny
2017-12-26 19:41               ` Dave Caswell
2017-12-26 23:44                 ` Steven Penny
2017-12-27  1:11                   ` cyg Simple
2017-12-27  1:16                     ` Steven Penny
2017-12-27  1:38                       ` Jürgen Wagner
2017-12-27 22:46                         ` Steven Penny
2017-12-27  9:39                     ` Steven Penny
2017-12-28 12:07                       ` cyg Simple
2017-12-28 20:11                         ` Steven Penny
2017-12-26 22:44               ` cyg Simple

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).