Question

I want use erl_tidy to format erlang code, including escript files. But this comes out when I format one escript file (source) after adding -module(erl_pprint). :

1> erl_tidy:file("erl_pprint").
erl_pprint: error: cannot determine module name.
** exception exit: error

But When I remove the she-bang line #!/usr/bin/env escript, formatting goes well. So how can I formatteing the code while keep the she-bang line?

Was it helpful?

Solution

You can't treat an escript file as a normal module and give it to erl_tidy. Perhaps you can drop the comment lines using "tail -n+2 erl_pprint > /tmp/erl_pprint.erl", run erl_tidy on the temp file, and then use "cat escript-header.txt /tmp/erl_pprint.erl > erl_pprint.new", if you create a file called escript-header.txt containing the leading shebang line (or lines).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top