The -r switch

42 views
Skip to first unread message

Hal Fulton

unread,
Jun 13, 2016, 3:19:38 PM6/13/16
to elixir-lang-talk
I'm trying to figure out *exactly* how this works.

So... i have three trivial scripts:

$ cat a1.exs
IO.puts "This is a1"

$ cat a2.exs
IO.puts "This is a2"

$ cat duh.exs
require MyMod
IO.puts "duh"

I'm curious as to why these commands are different:
 
$ elixir -r *.exs
This is a1
This is a2

$ elixir -r "*.exs"
This is a1
This is a2
duh

Note that in the first case, duh.exs is apparently not run.

Thanks,
Hal

José Valim

unread,
Jun 13, 2016, 3:34:04 PM6/13/16
to elixir-l...@googlegroups.com
$ elixir -r *.exs
This is a1
This is a2

This one is expanded by the OS. This means that it becomes:

elixir -r a1.exs a2.exs duh.exs

Which means a1 is required, a2 is executed as a script and duh.exs is passed to System.argv.

$ elixir -r "*.exs"
This is a1
This is a2
duh

This is expanded by Elixir, which means everything is properly required.

Hal Fulton

unread,
Jun 13, 2016, 3:40:11 PM6/13/16
to elixir-lang-talk
On Mon, Jun 13, 2016 at 2:33 PM, José Valim <jose....@plataformatec.com.br> wrote:

This one is expanded by the OS. This means that it becomes:

elixir -r a1.exs a2.exs duh.exs

Which means a1 is required, a2 is executed as a script and duh.exs is passed to System.argv.

 
This is expanded by Elixir, which means everything is properly required.


Ahh, of course, thank you.

I was thinking for a moment that the shell expanded inside double quotes and honored single quotes.

Hal

Reply all
Reply to author
Forward
0 new messages