[erlang-patches] [erlang-questions] A potential fix for escript on Windows

Henrik Nord <>
Mon Dec 12 16:40:11 CET 2011


Email has not yet arrived so resending,

This is included in 'pu'
Thank you for the contribution

On 11/25/2011 10:06 AM, Dave Cottlehuber wrote:
> Hi EP,
>
> escript currently only supports being started as "escript.exe" from
> the Windows command shell. The far more common "escript" which when
> called directly from the Windows cmd.exe shell does not parse the
> remaining arguments correctly. For comparison, you'd not type in
> "dir.exe" on Windows much.
>
> I've also hit the same issue as Pierre whilst using rebar on Windows,
> and he's agreed to allow me to submit his straightforward patch, now
> against the R15A master branch, to support both styles:
>
> git fetch git://github.com/dch/otp.git dch-fix-win32-escript
>
> https://github.com/dch/otp/compare/dch-fix-win32-escript
> https://github.com/dch/otp/compare/dch-fix-win32-escript.patch
>
> Thanks
> Dave
>
> On 5 June 2011 00:33, Pierre Rouleau<>  wrote:
>> OK, I think I know why escript is not accepting scrips unless it's invoked
>> as escript.exe.
>> I took a look at erts/etc/common/escript.c which I believe is the source for
>> escript.
>> I think one of the problem under Windows is the fact that when  escript's
>> main() is looking for the escript basename, it does not consider that, under
>> Windows, it could very well be escript (just as much as escript.exe).  If
>> the invocation line is "escript the_scrip_file.erl arguments", then escript
>> thinks the argv[0] is the name of the script (instead of escript executable)
>> and appends ".escript" to it.
>> One way to solve this problem under Windows, from what I can tell so far,
>> would be to check for escript.exe as well as escript under Windows, as the
>> following patch to escript does (from the R14B03 source taken at
>> erlang.org):
>>
>> @@ -377,7 +377,8 @@
>>       last_opt = argv;
>>
>>   #ifdef __WIN32__
>> -    if (_stricmp(basename, "escript.exe") == 0) {
>> +    if ( (_stricmp(basename, "escript.exe") == 0)
>> +       ||(_stricmp(basename, "escript") == 0)) {
>>   #else
>>       if (strcmp(basename, "escript") == 0) {
>>   #endif
>>
>> I have not yet tested that patch (I am still downloading Cygwin's
>> development package to be able to build Erlang from source on the Windows
>> box).
>> If I get it working, should I (and where should I) submit a patch to
>> escript.c?
>> Also, is there a bug tracker for Erlang where one can browse through bug
>> reports, submit one and identify patches or is everything done through the
>> mailing lists?  I did not see links to a bug tracker in the erlang.org site
>> except for a mention about submitting patches via github.
>> And finally, is there a documented process for development?
>> Thanks
>> -- Pierre Rouleau
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
> _______________________________________________
> erlang-patches mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-patches

-- 
/Henrik Nord Erlang/OTP



More information about the erlang-patches mailing list