Escript changes behavior of functions?

I am new to elixir and I decided to learn it by writing a small CLI app for personal use. I use the OptionParser module to parse the passed parameters, so I have this function:

      def main(arguments) do
        |> execute_function

      defp execute_function(["run" | params]) do
        IO.inspect params
        {opts,a,b}= OptionParser.parse(
          aliases: [d: :db_name],
          switches: [db_name: :string])
        |> IO.inspect

if i call it from iex:

iex(1)> Potion.CLI.main(["run", "-d", "test", "--dev=qweb,xml"])
["-d", "test", "--dev=qweb,xml"]
{[db_name: "test", dev: "qweb,xml"], [], []}
{[db_name: "test", dev: "qweb,xml"], [], []}

everything is fine and works as expected. If i build it with escript though:

$ rm -rf potion && mix
Generated escript potion with MIX_ENV=dev

$ ./potion run -d test --dev=xml,qweb
["-d", "test", "--dev=xml,qweb"]
{[db_name: "test"], [], []}

So the question is: is it a bug or am I missing something?

Elixir - 1.7.3
erlang-nox - 21.1.3

Okay, after a little bit of research and docs reading - OptionParser says that this behaviour can be possible here
so passing the key allow_nonexistent_atoms solves the issue I had. Can be locked and marked as answered. I am sorry :frowning:


You can mark as answered on your own, just click the boxed checkmark below the post that answers the question. You might need to expand the posts options first by clicking on the three dots. I’ll mark your post as the answer in the meantime.