The issue here is that when shellout.arguments() is used with the Erlang platform gleam run -- ARGS works differently from escript SCRIPT ARGS.
gleam run
Shell: gleam run -- one two three
Args: shellout.arguments() == ["one", "two", "three"]
escript
Shell: ./script one two three
Args: shellout.arguments() == ["./script", "one", "two", "three"]
The annoying thing here is how the behavior changes not that one is necessarily more correct than the other. I often use gleam run during testing and expect the compiled escript to behave the same way.
For anyone else running into this issue, the argv library does handle escripts consistently.
The issue here is that when
shellout.arguments()is used with the Erlang platformgleam run -- ARGSworks differently fromescript SCRIPT ARGS.gleam runShell:
gleam run -- one two threeArgs:
shellout.arguments() == ["one", "two", "three"]escriptShell:
./script one two threeArgs:
shellout.arguments() == ["./script", "one", "two", "three"]The annoying thing here is how the behavior changes not that one is necessarily more correct than the other. I often use
gleam runduring testing and expect the compiled escript to behave the same way.For anyone else running into this issue, the
argvlibrary does handle escripts consistently.