Passing argument from the command line

Mickael Remond mickael.remond@REDACTED
Thu Oct 12 14:22:55 CEST 2000


It seems that the argument of the Erlang command line are always list of
atoms...
Is it right or am I missing something ?

In fact, whith this fact you need to design your functions specifically if you
want them to be called directly from the command line and from the Erlang
shell.

For example: I was building a makefile to transform .ehtml into .html files.

The command I am using is:

 erl -s ehtml file index -s init stop

And it does not work from the command line.



I have changed the following code in ehtml.erl:

file(F) when list(F) ->
    file(F ++ ".ehtml", F ++ ".html").

into:

% Called from the command line
file([F|Empty]) when atom(F), Empty==[] ->
    file(atom_to_list(F));
% Called from the Erlang Shell
file(F) when list(F) ->
    file(F ++ ".ehtml", F ++ ".html").

And the command line is working.

Am I missing something or must I make sure that all function that need to be
command line compliant should accept list of atoms ?

Thank you for help.

-- 
Mickaël Rémond



More information about the erlang-questions mailing list