unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#7784: executable-find does not find scripts on woe32
@ 2011-01-04 23:44 Sam Steingold
  2011-01-05  1:18 ` Óscar Fuentes
  2011-01-05  7:14 ` Jason Rumney
  0 siblings, 2 replies; 11+ messages in thread
From: Sam Steingold @ 2011-01-04 23:44 UTC (permalink / raw)
  To: 7784

GNU Emacs 23.2.1 (i386-mingw-nt5.2.3790)
 of 2010-05-08 on G41R2F1
--with-gcc (3.4) --no-opt --cflags -Ic:/xpm/include

(executable-find "bzr")
==> nil
(executable-find "svn")
==> "c:/gnu/cygwin/bin/svn.exe"

the problem, apparently, stems from:

(file-exists-p "c:/gnu/cygwin/bin/bzr")
==> t
(file-executable-p "c:/gnu/cygwin/bin/bzr")
==> nil
which is wrong because bzr is an executable python script.


-- 
Sam Steingold <http://sds.podval.org>





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

* bug#7784: executable-find does not find scripts on woe32
  2011-01-04 23:44 bug#7784: executable-find does not find scripts on woe32 Sam Steingold
@ 2011-01-05  1:18 ` Óscar Fuentes
  2011-01-05  4:05   ` Sam Steingold
  2011-01-05 11:30   ` Eli Zaretskii
  2011-01-05  7:14 ` Jason Rumney
  1 sibling, 2 replies; 11+ messages in thread
From: Óscar Fuentes @ 2011-01-05  1:18 UTC (permalink / raw)
  To: Sam Steingold; +Cc: 7784

Sam Steingold <sds@gnu.org> writes:

> (file-executable-p "c:/gnu/cygwin/bin/bzr")
> ==> nil
> which is wrong because bzr is an executable python script.

How does Emacs know that bzr is a Python script? Because it has

#!/usr/bin/python

as the first line? That only makes sense within the Cygwin environment,
i.e. if you are running a Cygwin-based Emacs.

As you know, there is no 'executable' attribute on Windows. Cygwin fakes
it.





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

* bug#7784: executable-find does not find scripts on woe32
  2011-01-05  1:18 ` Óscar Fuentes
@ 2011-01-05  4:05   ` Sam Steingold
  2011-01-05 11:26     ` Eli Zaretskii
  2011-01-05 11:30   ` Eli Zaretskii
  1 sibling, 1 reply; 11+ messages in thread
From: Sam Steingold @ 2011-01-05  4:05 UTC (permalink / raw)
  To: Óscar Fuentes; +Cc: 7784

On Tue, Jan 4, 2011 at 8:18 PM, Óscar Fuentes <ofv@wanadoo.es> wrote:
> Sam Steingold <sds@gnu.org> writes:
>
>> (file-executable-p "c:/gnu/cygwin/bin/bzr")
>> ==> nil
>> which is wrong because bzr is an executable python script.
>
> As you know, there is no 'executable' attribute on Windows.

that's correct.
therefore the emacs code which calls stat() on the filename and checks
the mode is wrong.
check_executable() should return true for all arguments.



-- 
Sam Steingold <http://sds.podval.org>





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

* bug#7784: executable-find does not find scripts on woe32
  2011-01-04 23:44 bug#7784: executable-find does not find scripts on woe32 Sam Steingold
  2011-01-05  1:18 ` Óscar Fuentes
@ 2011-01-05  7:14 ` Jason Rumney
  1 sibling, 0 replies; 11+ messages in thread
From: Jason Rumney @ 2011-01-05  7:14 UTC (permalink / raw)
  To: bug-gnu-emacs

On 05/01/2011 07:44, Sam Steingold wrote:
> GNU Emacs 23.2.1 (i386-mingw-nt5.2.3790)
>   of 2010-05-08 on G41R2F1
> --with-gcc (3.4) --no-opt --cflags -Ic:/xpm/include
>
> (executable-find "bzr")
> ==>  nil
> (executable-find "svn")
> ==>  "c:/gnu/cygwin/bin/svn.exe"
>
> the problem, apparently, stems from:
>
> (file-exists-p "c:/gnu/cygwin/bin/bzr")
> ==>  t
> (file-executable-p "c:/gnu/cygwin/bin/bzr")
> ==>  nil
> which is wrong because bzr is an executable python script.
>    

It may well be, but Windows does not know how to execute it.  You either 
need to run it by specifying the script as an argument to python.exe 
explicitly, or run it from within Cygwin bash, which interprets the #! 
comment syntax and presumably has some Cygwin specific way to simulate 
the executable bit in the filesystem.







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

* bug#7784: executable-find does not find scripts on woe32
  2011-01-05  4:05   ` Sam Steingold
@ 2011-01-05 11:26     ` Eli Zaretskii
  2011-01-05 14:24       ` Óscar Fuentes
  2011-01-05 14:40       ` Sam Steingold
  0 siblings, 2 replies; 11+ messages in thread
From: Eli Zaretskii @ 2011-01-05 11:26 UTC (permalink / raw)
  To: Sam Steingold; +Cc: ofv, 7784

> Date: Tue, 4 Jan 2011 23:05:16 -0500
> From: Sam Steingold <sds@gnu.org>
> Cc: 7784@debbugs.gnu.org
> 
> check_executable() should return true for all arguments.

How would this be useful?  Right now, it returns true for files that
you can "execute" from the native Windows build of Emacs using native
Windows shells and the cmd proxy that is part of the Emacs package.
Returning true for every file will give gobs of false positives,
because most files on Windows are not executable, not even by Cygwin
wizardry.

Could you please describe the specific use-case where this issue got
in your way?  Because otherwise this discussion sounds a bit academic
to me.





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

* bug#7784: executable-find does not find scripts on woe32
  2011-01-05  1:18 ` Óscar Fuentes
  2011-01-05  4:05   ` Sam Steingold
@ 2011-01-05 11:30   ` Eli Zaretskii
  1 sibling, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2011-01-05 11:30 UTC (permalink / raw)
  To: Óscar Fuentes; +Cc: 7784, sds

> From: Óscar Fuentes <ofv@wanadoo.es>
> Date: Wed, 05 Jan 2011 02:18:04 +0100
> Cc: 7784@debbugs.gnu.org
> 
> As you know, there is no 'executable' attribute on Windows. Cygwin fakes
> it.

Actually, there is an execute permission bit on Windows, but only on
NTFS; Cygwin uses that to "fake" Posix-style x bit.  But Emacs (the
native Windows build of it) does not use these NTFS features, and
frankly, I'm not sure it's worth the hassle (and there _is_ a very
real hassle, because mapping Posix rwx bits into NTFS ACLs is a
non-trivial job).

But I digress.  The real question in this bug report is why did the
OP need a Python script to appear as executable to Emacs.





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

* bug#7784: executable-find does not find scripts on woe32
  2011-01-05 11:26     ` Eli Zaretskii
@ 2011-01-05 14:24       ` Óscar Fuentes
  2011-01-05 16:25         ` Eli Zaretskii
  2011-01-05 14:40       ` Sam Steingold
  1 sibling, 1 reply; 11+ messages in thread
From: Óscar Fuentes @ 2011-01-05 14:24 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 7784, Sam Steingold

Eli Zaretskii <eliz@gnu.org> writes:

> How would this be useful?  Right now, it returns true for files that
> you can "execute" from the native Windows build of Emacs using native
> Windows shells and the cmd proxy that is part of the Emacs package.

One thing I noticed while experimenting with file-executable-p is that
it returns false for files with extensions listed in PATHEXT. For
instance, .JS is listed on one machine's PATHEXT but, after creating
foo.js, (file-executable-p "foo.js") returns nil.

As those files are directly executable from the shell, maybe Emacs
should recognize them as executables as well?

[snip]





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

* bug#7784: executable-find does not find scripts on woe32
  2011-01-05 11:26     ` Eli Zaretskii
  2011-01-05 14:24       ` Óscar Fuentes
@ 2011-01-05 14:40       ` Sam Steingold
  2011-01-05 16:24         ` Eli Zaretskii
  1 sibling, 1 reply; 11+ messages in thread
From: Sam Steingold @ 2011-01-05 14:40 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: ofv, 7784

On Wed, Jan 5, 2011 at 6:26 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> Date: Tue, 4 Jan 2011 23:05:16 -0500
>> From: Sam Steingold <sds@gnu.org>
>> Cc: 7784@debbugs.gnu.org
>>
>
> Could you please describe the specific use-case where this issue got
> in your way?  Because otherwise this discussion sounds a bit academic
> to me.

when I try to use cygwin in native windows emacs, this works for
binaries but not for scripts.
e.g., using VC with cygwin-provided bzr and hg does not work.
there is no reason for this not to work except for the
check_executable()'s return value.


-- 
Sam Steingold <http://sds.podval.org>





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

* bug#7784: executable-find does not find scripts on woe32
  2011-01-05 14:40       ` Sam Steingold
@ 2011-01-05 16:24         ` Eli Zaretskii
  0 siblings, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2011-01-05 16:24 UTC (permalink / raw)
  To: Sam Steingold; +Cc: ofv, 7784

> Date: Wed, 5 Jan 2011 09:40:06 -0500
> From: Sam Steingold <sds@gnu.org>
> Cc: ofv@wanadoo.es, 7784@debbugs.gnu.org
> 
> On Wed, Jan 5, 2011 at 6:26 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> >> Date: Tue, 4 Jan 2011 23:05:16 -0500
> >> From: Sam Steingold <sds@gnu.org>
> >> Cc: 7784@debbugs.gnu.org
> >>
> >
> > Could you please describe the specific use-case where this issue got
> > in your way?  Because otherwise this discussion sounds a bit academic
> > to me.
> 
> when I try to use cygwin in native windows emacs, this works for
> binaries but not for scripts.
> e.g., using VC with cygwin-provided bzr and hg does not work.

Using any Emacs command that goes through shell-command-* should work
if you configure Emacs to use the Cygwin Bash as the shell.

Emacs commands that invoke programs directly (call/start-process etc.)
will not work with Unix shell scripts, but you can craft trivial *.bat
files that invoke the script via the Cygwin Bash, and put them on
PATH.  E.g., to invoke Cygwin bzr, create a bzr.bat (untested) with
this single line:

 @X:\path\to\cygwin\bash $*

> there is no reason for this not to work except for the
> check_executable()'s return value.

Yes, there is a reason: the native Windows build of Emacs uses native
Windows APIs to run subprocesses, and those APIs don't know how to run
a Unix shell script.

Or maybe I misunderstand the details, in which case please tell more
regarding the Emacs functions which failed (those that eventually
called executable-find) and the relevant error message(s).

In general, though, if you want to use Cygwin tools, I suggest to use
a Cygwin build of Emacs.  Then everything should "just work".






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

* bug#7784: executable-find does not find scripts on woe32
  2011-01-05 14:24       ` Óscar Fuentes
@ 2011-01-05 16:25         ` Eli Zaretskii
  2011-01-05 23:13           ` Jason Rumney
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2011-01-05 16:25 UTC (permalink / raw)
  To: Óscar Fuentes; +Cc: 7784, sds

> From: Óscar Fuentes <ofv@wanadoo.es>
> Cc: Sam Steingold <sds@gnu.org>, 7784@debbugs.gnu.org
> Date: Wed, 05 Jan 2011 15:24:26 +0100
> 
> One thing I noticed while experimenting with file-executable-p is that
> it returns false for files with extensions listed in PATHEXT. For
> instance, .JS is listed on one machine's PATHEXT but, after creating
> foo.js, (file-executable-p "foo.js") returns nil.
> 
> As those files are directly executable from the shell, maybe Emacs
> should recognize them as executables as well?

Patches for supporting PATHEXT are most welcome, TIA.






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

* bug#7784: executable-find does not find scripts on woe32
  2011-01-05 16:25         ` Eli Zaretskii
@ 2011-01-05 23:13           ` Jason Rumney
  0 siblings, 0 replies; 11+ messages in thread
From: Jason Rumney @ 2011-01-05 23:13 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Óscar Fuentes, 7784, sds

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Óscar Fuentes <ofv@wanadoo.es>
>> Cc: Sam Steingold <sds@gnu.org>, 7784@debbugs.gnu.org
>> Date: Wed, 05 Jan 2011 15:24:26 +0100
>> 
>> One thing I noticed while experimenting with file-executable-p is that
>> it returns false for files with extensions listed in PATHEXT. For
>> instance, .JS is listed on one machine's PATHEXT but, after creating
>> foo.js, (file-executable-p "foo.js") returns nil.
>> 
>> As those files are directly executable from the shell, maybe Emacs
>> should recognize them as executables as well?
>
> Patches for supporting PATHEXT are most welcome, TIA.

It might also be a good idea to merge the list used by is_exec in w32.c
with the list that is used as the initial value of exec-suffixes.





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

end of thread, other threads:[~2011-01-05 23:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-04 23:44 bug#7784: executable-find does not find scripts on woe32 Sam Steingold
2011-01-05  1:18 ` Óscar Fuentes
2011-01-05  4:05   ` Sam Steingold
2011-01-05 11:26     ` Eli Zaretskii
2011-01-05 14:24       ` Óscar Fuentes
2011-01-05 16:25         ` Eli Zaretskii
2011-01-05 23:13           ` Jason Rumney
2011-01-05 14:40       ` Sam Steingold
2011-01-05 16:24         ` Eli Zaretskii
2011-01-05 11:30   ` Eli Zaretskii
2011-01-05  7:14 ` Jason Rumney

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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