public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Why can't run.exe execute a shebang script directly?
@ 2014-10-24 13:08 John Wiersba
  2014-10-24 13:50 ` Andrey Repin
  2014-10-24 13:53 ` Corinna Vinschen
  0 siblings, 2 replies; 9+ messages in thread
From: John Wiersba @ 2014-10-24 13:08 UTC (permalink / raw)
  To: cygwin

I would have thought cygwin1.dll contains the code necessary to do this, like the linux kernel does.  Can it be added to the dll or does it have to be added to each executable individually, such as bash.exe, run.exe, etc.?

  bash$ /bin/run ./try
  run FATAL: Could not start D:\ftp\try

--
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] 9+ messages in thread

* Re: Why can't run.exe execute a shebang script directly?
  2014-10-24 13:08 Why can't run.exe execute a shebang script directly? John Wiersba
@ 2014-10-24 13:50 ` Andrey Repin
  2014-10-24 14:57   ` Warren Young
  2014-10-24 13:53 ` Corinna Vinschen
  1 sibling, 1 reply; 9+ messages in thread
From: Andrey Repin @ 2014-10-24 13:50 UTC (permalink / raw)
  To: John Wiersba, cygwin

Greetings, John Wiersba!

> I would have thought cygwin1.dll contains the code necessary to do this,
> like the linux kernel does.  Can it be added to the dll or does it have to
> be added to each executable individually, such as bash.exe, run.exe, etc.?

>   bash$ /bin/run ./try
>   run FATAL: Could not start D:\ftp\try

All right except the fact that run.exe is designed to start Windows
applications (or associations). It just doesn't try the cygwin magic on the
files it tries to start. I suggest /bin/env instead.


--
WBR,
Andrey Repin (anrdaemon@yandex.ru) 24.10.2014, <17:35>

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] 9+ messages in thread

* Re: Why can't run.exe execute a shebang script directly?
  2014-10-24 13:08 Why can't run.exe execute a shebang script directly? John Wiersba
  2014-10-24 13:50 ` Andrey Repin
@ 2014-10-24 13:53 ` Corinna Vinschen
  2014-10-24 13:57   ` Eric Blake
  2014-10-24 15:22   ` John Wiersba
  1 sibling, 2 replies; 9+ messages in thread
From: Corinna Vinschen @ 2014-10-24 13:53 UTC (permalink / raw)
  To: cygwin

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

On Oct 24 06:05, John Wiersba wrote:
> I would have thought cygwin1.dll contains the code necessary to do this, like the linux kernel does.  Can it be added to the dll or does it have to be added to each executable individually, such as bash.exe, run.exe, etc.?
> 
>   bash$ /bin/run ./try
>   run FATAL: Could not start D:\ftp\try

run.exe doesn't start the executable via a Cygwin function, but via a
Windows call.  There's no chance for the DLL to handle shebangs.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: Why can't run.exe execute a shebang script directly?
  2014-10-24 13:53 ` Corinna Vinschen
@ 2014-10-24 13:57   ` Eric Blake
  2014-10-24 14:52     ` Warren Young
  2014-10-24 15:22   ` John Wiersba
  1 sibling, 1 reply; 9+ messages in thread
From: Eric Blake @ 2014-10-24 13:57 UTC (permalink / raw)
  To: cygwin

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

On 10/24/2014 07:53 AM, Corinna Vinschen wrote:
> On Oct 24 06:05, John Wiersba wrote:
>> I would have thought cygwin1.dll contains the code necessary to do this, like the linux kernel does.  Can it be added to the dll or does it have to be added to each executable individually, such as bash.exe, run.exe, etc.?
>>
>>   bash$ /bin/run ./try
>>   run FATAL: Could not start D:\ftp\try
> 
> run.exe doesn't start the executable via a Cygwin function, but via a
> Windows call.  There's no chance for the DLL to handle shebangs.

Of course, if you wanted to be nice, you could write a patch to run.exe
that teaches it to read() the contents of a file that it is about to
execute, and if it starts with a shebang, run the interpreter directly
instead of handing things off to the Windows call (and maybe make this
mode optional, requiring a command line option to turn on?).  This is
open source, after all.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

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

* Re: Why can't run.exe execute a shebang script directly?
  2014-10-24 13:57   ` Eric Blake
@ 2014-10-24 14:52     ` Warren Young
  0 siblings, 0 replies; 9+ messages in thread
From: Warren Young @ 2014-10-24 14:52 UTC (permalink / raw)
  To: cygwin

On Oct 24, 2014, at 7:57 AM, Eric Blake <eblake@redhat.com> wrote:

> On 10/24/2014 07:53 AM, Corinna Vinschen wrote:
>> On Oct 24 06:05, John Wiersba wrote:
>>> I would have thought cygwin1.dll contains the code necessary to do this, like the linux kernel does.
>> 
>> run.exe doesn't start the executable via a Cygwin function, but via a
>> Windows call.  There's no chance for the DLL to handle shebangs.
> 
> Of course, if you wanted to be nice, you could write a patch to run.exe
> that teaches it to read() the contents of a file that it is about to
> execute, and if it starts with a shebang…

I get that run.exe must do low-level Win32 API things in order to suppress the console window, which is why it is currently a native app, rather than a Cygwin app, but I don’t like the idea of reinventing execve(2) inside run.exe.
--
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] 9+ messages in thread

* Re: Why can't run.exe execute a shebang script directly?
  2014-10-24 13:50 ` Andrey Repin
@ 2014-10-24 14:57   ` Warren Young
  0 siblings, 0 replies; 9+ messages in thread
From: Warren Young @ 2014-10-24 14:57 UTC (permalink / raw)
  To: cygwin

On Oct 24, 2014, at 7:37 AM, Andrey Repin <anrdaemon@yandex.ru> wrote:

> run.exe is designed to start Windows
> applications (or associations).

…or associations?

Are you confusing run.exe with cygstart.exe?

$ touch foo.txt
$ run foo.txt
run FATAL: Could not start C:\cygwin64\home\Warren\foo.txt
$ cygstart foo.txt      # Notepad opens, as expected
--
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] 9+ messages in thread

* Re: Why can't run.exe execute a shebang script directly?
  2014-10-24 13:53 ` Corinna Vinschen
  2014-10-24 13:57   ` Eric Blake
@ 2014-10-24 15:22   ` John Wiersba
  2014-10-24 15:26     ` Eric Blake
  1 sibling, 1 reply; 9+ messages in thread
From: John Wiersba @ 2014-10-24 15:22 UTC (permalink / raw)
  To: cygwin

> From: Corinna Vinschen <corinna-cygwin@cygwin.com>

>
> On Oct 24 06:05, John Wiersba wrote:
> 
>>  I would have thought cygwin1.dll contains the code necessary to do this, 
> like the linux kernel does.  Can it be added to the dll or does it have to be 
> added to each executable individually, such as bash.exe, run.exe, etc.?
>> 
>>    bash$ /bin/run ./try
>>    run FATAL: Could not start D:\ftp\try
> 
> run.exe doesn't start the executable via a Cygwin function, but via a
> Windows call.  There's no chance for the DLL to handle shebangs.

Thanks, Corinna!  This is the real reason.  

I thought that all (or virtually all) cygwin-supplied programs that start 
other programs use the cygwin1.dll execve(2) emulation to start them, because 
the execve emulation can be used to start *both* cygwin programs and windows 
native programs.  Or at least it seems that way to me.

Is there be in drawback to having run.exe start its target program using
the execve emulation in cygwin1.dll, rather than using a Windows call to
start the target executable?

--
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] 9+ messages in thread

* Re: Why can't run.exe execute a shebang script directly?
  2014-10-24 15:22   ` John Wiersba
@ 2014-10-24 15:26     ` Eric Blake
  2014-10-24 16:43       ` John Wiersba
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Blake @ 2014-10-24 15:26 UTC (permalink / raw)
  To: cygwin

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

On 10/24/2014 09:19 AM, John Wiersba wrote:

> I thought that all (or virtually all) cygwin-supplied programs that start 
> other programs use the cygwin1.dll execve(2) emulation to start them, because 
> the execve emulation can be used to start *both* cygwin programs and windows 
> native programs.  Or at least it seems that way to me.
> 
> Is there be in drawback to having run.exe start its target program using
> the execve emulation in cygwin1.dll, rather than using a Windows call to
> start the target executable?

run.exe is special.  In order to hide consoles, it MUST use native
windows API instead of cygwin1.dll calls.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

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

* Re: Why can't run.exe execute a shebang script directly?
  2014-10-24 15:26     ` Eric Blake
@ 2014-10-24 16:43       ` John Wiersba
  0 siblings, 0 replies; 9+ messages in thread
From: John Wiersba @ 2014-10-24 16:43 UTC (permalink / raw)
  To: Eric Blake, cygwin

> From: Eric Blake <eblake@redhat.com>

> On 10/24/2014 09:19 AM, John Wiersba wrote:
>
>>  I thought that all (or virtually all) cygwin-supplied programs that start 
>>  other programs use the cygwin1.dll execve(2) emulation to start them, 
> because 
>>  the execve emulation can be used to start *both* cygwin programs and 
> windows 
>>  native programs.  Or at least it seems that way to me.
>> 
>>  Is there be in drawback to having run.exe start its target program using
>>  the execve emulation in cygwin1.dll, rather than using a Windows call to
>>  start the target executable?
> 
> run.exe is special.  In order to hide consoles, it MUST use native
> windows API instead of cygwin1.dll calls.

OK -- I guess that settles it, then!  Thanks!


--
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] 9+ messages in thread

end of thread, other threads:[~2014-10-24 16:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-24 13:08 Why can't run.exe execute a shebang script directly? John Wiersba
2014-10-24 13:50 ` Andrey Repin
2014-10-24 14:57   ` Warren Young
2014-10-24 13:53 ` Corinna Vinschen
2014-10-24 13:57   ` Eric Blake
2014-10-24 14:52     ` Warren Young
2014-10-24 15:22   ` John Wiersba
2014-10-24 15:26     ` Eric Blake
2014-10-24 16:43       ` John Wiersba

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