Erlang/OTP Forums

Author Message

<  Erlang questions mailing list  ~  erl, escript, shebangs and syntax errors

mcandre
Posted: Thu Sep 29, 2011 6:26 pm Reply with quote
Joined: 26 Feb 2011 Posts: 2
Please instruct erl to ignore shebangs.

$ cat hello.erl
View user's profile Send private message
Zert
Posted: Fri Sep 30, 2011 1:33 am Reply with quote
User Joined: 03 Dec 2007 Posts: 32
You should not compile this script, just run. Remove first line If you want compile it as regular erlang module.

On 30 September 2011 01:25, Andrew Pennebaker <andrew.pennebaker@gmail.com (andrew.pennebaker@gmail.com)> wrote:
Quote:
Please instruct erl to ignore shebangs.

$ cat hello.erl 
#!/usr/bin/env escript


-module(hello).
-export([main/1]).


main(_) -> io:format("Hello World!~n", []).wonko:Desktop andrew$ ./hello.erl 
Hello World!
wonko:Desktop andrew$ erl
Erlang R14B03 (erts-5.8.4) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]


Eshell V5.8.4  (abort with ^G)
1> c(hello).
./hello.erl:1: syntax error before: '#'
./hello.erl:4: no module definition
error


Cheers,

Andrew Pennebaker
www.yellosoft.us


_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org (erlang-questions@erlang.org)
http://erlang.org/mailman/listinfo/erlang-questions





--
Maxim Treskin

Post received from mailinglist
View user's profile Send private message
Zert
Posted: Fri Sep 30, 2011 2:32 am Reply with quote
User Joined: 03 Dec 2007 Posts: 32
Programming is not an intuitive job, people are not programmed from birth, so there is different ways to be intuitive for different people. For example I see nothing intuitive to mix escript code and code for OTP. If you want to use common library in OTP application and escript, put following line after shebang line: %%! -pa path/to/library

On 30 September 2011 09:07, Andrew Pennebaker <andrew.pennebaker@gmail.com (andrew.pennebaker@gmail.com)> wrote:
Quote:
No. erl should ignore shebang lines, because that's easy to do in a parser, and it makes the language more intuitive to program in.

Cheers,

Andrew Pennebaker
www.yellosoft.us



On Thu, Sep 29, 2011 at 9:33 PM, Maxim Treskin <zerthurd@gmail.com (zerthurd@gmail.com)> wrote:
Quote:
You should not compile this script, just run. Remove first line If you want compile it as regular erlang module.


On 30 September 2011 01:25, Andrew Pennebaker <andrew.pennebaker@gmail.com (andrew.pennebaker@gmail.com)> wrote:


Quote:

Please instruct erl to ignore shebangs.

$ cat hello.erl 
#!/usr/bin/env escript


-module(hello).
-export([main/1]).


main(_) -> io:format("Hello World!~n", []).wonko:Desktop andrew$ ./hello.erl 
Hello World!
wonko:Desktop andrew$ erl
Erlang R14B03 (erts-5.8.4) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]


Eshell V5.8.4  (abort with ^G)
1> c(hello).
./hello.erl:1: syntax error before: '#'
./hello.erl:4: no module definition
error


Cheers,

Andrew Pennebaker
www.yellosoft.us




_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org (erlang-questions@erlang.org)
http://erlang.org/mailman/listinfo/erlang-questions





--
Maxim Treskin








--
Maxim Treskin


Post received from mailinglist
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum