Skip to content

Commit c7a2442

Browse files
committed
Make sure all Erlang parameters are extracted and parsed in elixir.bat
1 parent f88ee1c commit c7a2442

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

bin/elixir.bat

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@echo off
22
set argc=0
33
for %%x in (%*) do set /A argc+=1
4-
if %argc% == 0 (
4+
if %argc%== 0 (
55
goto documentation
66
) else (
7-
goto run
7+
goto parseopts
88
)
99
:documentation
1010
echo Usage: %~nx0 [options] [.exs file] [data]
@@ -21,5 +21,47 @@ echo.
2121
echo ** Options marked with (*) can be given more than once
2222
echo ** Options given after the .exs file or -- are passed down to the executed code
2323
echo ** Options can be passed to the erlang runtime using ELIXIR_ERL_OPTS
24+
goto :EOF
25+
26+
:parseopts
27+
28+
rem parameters for Erlang
29+
set parsErlang=
30+
31+
rem make sure we keep a copy of all parameters
32+
set allPars=%*
33+
34+
rem Recursive loop called for each parameter
35+
:startloop
36+
set par=%1
37+
shift
38+
if "%par%"=="" (
39+
rem if no parameters defined
40+
goto :run
41+
)
42+
for /f "usebackq" %%m in (`echo %par%^|findstr \--detached`) do (
43+
set parsErlang=%parsErlang% -detached
44+
goto:startloop
45+
)
46+
for /f "usebackq" %%m in (`echo %par%^|findstr \--hidden`) do (
47+
set parsErlang=%parsErlang% -hidden
48+
goto:startloop
49+
)
50+
for /f "usebackq" %%m in (`echo %par%^|findstr \--cookie`) do (
51+
set parsErlang=%parsErlang% -setcookie %1
52+
shift
53+
goto:startloop
54+
)
55+
for /f "usebackq" %%m in (`echo %par%^|findstr \--sname`) do (
56+
set parsErlang=%parsErlang% -sname %1
57+
shift
58+
goto:startloop
59+
)
60+
for /f "usebackq" %%m in (`echo %par%^|findstr \--name`) do (
61+
set parsErlang=%parsErlang% -name %1
62+
shift
63+
goto:startloop
64+
)
65+
goto:startloop
2466
:run
25-
erl -env ERL_LIBS %ERL_LIBS%;"%~dp0\..\lib" -noshell %ELIXIR_ERL_OPTS% -s elixir start_cli -extra %*
67+
erl -env ERL_LIBS %ERL_LIBS%;"%~dp0\..\lib" -noshell %ELIXIR_ERL_OPTS% %parsErlang% -s elixir start_cli -extra %allPars%

0 commit comments

Comments
 (0)