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

Support escript shebangs #131

Open
Zalastax opened this issue Apr 4, 2019 · 3 comments
Open

Support escript shebangs #131

Zalastax opened this issue Apr 4, 2019 · 3 comments

Comments

@Zalastax
Copy link

Zalastax commented Apr 4, 2019

When writing an escript, the file will start with a shebang, e.g. #!/usr/bin/env escript.
It would we very nice if the shebang didn't cause the plugin to fail completely.

@pgourlain
Copy link
Owner

Hi,

Sorry for the delay.

I am not used to using escript, can you give me detail about it ?
so i take a sample from erlang documention... but plugin didn't failed...

here is my sample :

#!/usr/bin/env escript
%% -- erlang --
%%! -smp enable -sname factorial -mnesia debug verbose
main([String]) ->
try
N = list_to_integer(String),
F = fac(N),
io:format("factorial ~w = ~w\n", [N,F])
catch
: ->
usage()
end;
main(_) ->
usage().

usage() ->
io:format("usage: factorial integer\n"),
halt(1).

fac(0) -> 1;
fac(N) -> N * fac(N-1).

@Zalastax
Copy link
Author

Zalastax commented Apr 18, 2019

The issue is quite weird it seems.

I took your sample and wrote it to a file test.erl. Setting the language to Erlang, everything works. However, if I restart the editor:

  • vscode opens the file test.erl automatically
  • the file's language is set to Erlang
  • I get an error on the first line: [erl] syntax error before: '#' (1, 1)

Switching the language to something else and then back to Erlang, the error disappears.

@KornelH
Copy link
Contributor

KornelH commented Sep 20, 2021

Hi,

In the mentioned example the first line is not part of the language at any means and ignored by escript (used by Linux shell). Since I've got no error on the first line I guess it's solved in the meantime. The second line is exclusively for Emacs as it was the de-facto editor in the good old days, other editors treat is as a simple comment without no meaning. The third line is used by escript if present but it's a simple comment even for Emacs.

Extension .escript is now associated to erlang extension. If other extensions are preferred then a VSC extension like Shebang Language Associator could be handy.

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

No branches or pull requests

3 participants