Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sys.executable_name is wrong if executable name contains dots #4719

Closed
vicuna opened this issue Feb 18, 2009 · 4 comments
Closed

Sys.executable_name is wrong if executable name contains dots #4719

vicuna opened this issue Feb 18, 2009 · 4 comments

Comments

@vicuna
Copy link

vicuna commented Feb 18, 2009

Original bug ID: 4719
Reporter: bartjacobs
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2015-12-11T18:19:59Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.11.0
Fixed in version: 4.02.0+dev
Category: platform support (windows, cross-compilation, etc)
Monitored by: bartjacobs

Bug description

Context: Ocaml 3.11.0 on Windows Vista SP1

mybug.ml:
print_endline Sys.executable_name

ocamlopt.opt -o mybug.exe mybug.ml
mybug
C:\test\mybug.exe
mybug.exe
C:\test\mybug.exe
ren mybug.exe mybug.foo.exe
mybug.foo.exe
C:\test\mybug.foo.exe
mybug.foo
mybug.foo

The last output is wrong.

@vicuna
Copy link
Author

vicuna commented Sep 14, 2012

Comment author: @damiendoligez

Under cygwin and OCaml 4.00.0, all four cases return the file name without the ".exe".
Need to check the other Windows ports.

@vicuna
Copy link
Author

vicuna commented Jun 14, 2013

Comment author: @alainfrisch

Under the MSVC ports, the last case returns "mybug.foo.exe" when called from a Cygwin shell, but "mybug.foo" when called from cmd.exe.

@vicuna
Copy link
Author

vicuna commented Jun 18, 2013

Comment author: @alainfrisch

In the same way, compiling in bytecode with "-custom", with a target containing a dot (foo.bar.exe) makes it impossible to run the program from cmd.exe.

I propose to implement caml_executable_name under Windows using GetModuleFileName(NULL, _, _). (Another option would be to rely on _pgmptr / _get_pgmptr, but its documention on MSDN is quite scary about its semantics when the program is not called from the command line.)

@vicuna
Copy link
Author

vicuna commented Jun 18, 2013

Comment author: @alainfrisch

Commit 13799 on trunk. I'm reluctant to include it in 4.01. If someone really cares about it, please shout!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants