bmitc
Apologies if I am missing something silly, but I am unable to figure this out. I am trying to run an Elixir script using mix run, and I want to pass a single arbitrary string to it.
A sample script, say scripts/string_parser.exs looks like this:
System.argv()
|> IO.inspect()
This example only contains the relevant parts. Here’s some sample runs of the script:
> mix run scripts/string_parser.exs '{:ok}'
["{:ok}"]
> mix run scripts/string_parser.exs '{:ok,:test}'
["{:ok", ":test}"]
> mix run scripts/string_parser.exs '{:ok\,:test}'
["{:ok\" :test}"]
> mix run scripts/string_parser.exs "{:ok,:test}"
["{:ok", ":test}"]
> mix run scripts/string_parser.exs "{:ok\,:test}"
["{:ok\" :test}"]
How do I pass a string that contains a , as a command line argument to mix run <script>?
Note: This issue does not occur for running a script with elixir <script> <arguments>. For example,
> elixir scripts/string_parser.exs '{:ok, :test}'
["{:ok, :test}"]
and all the other variations work as expected.
This either seems like a bug or I’m missing something.
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security











Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Sebb
use
"Edit: just saw, that you already tested that.
And that should work.
at least it does for me (linux, bash)
cocoa
It also works as expected for me. (macOS, zsh)
Perhaps you might want to share which OTP and Elixir version you are on, and probably also which operating system and shell you are using.
cocoa
Also these two (run # 3 and 5) runs look like perhaps your shell was doing something weird when escaping characters.
cmo
@bmitc are you on Windows by any chance?
mixismix.batormix.ps1and I think you’ll find that passing args on Windows is a nightmare due to the different shells and batch scripts vs PowerShell scripts.My determination was that it is not worth the effort trying to handle them and built an exe for my release instead of
<release>.bat. The Burrito project does something funky to handle the args on Windows too.You might have better luck doing your dev in WSL.
bmitc
I am indeed on Windows. I should have mentioned that, but it actually didn’t occur to me since
elixirworks as expected. I am on Windows 11 using PowerShell. My Elixir version is:I typically bounce between Windows and WSL2 and sometimes Docker for my development, depending on what I’m doing.
Does anyone know why
elixirworks andmixdoesn’t? It doesn’t seem to be solely a Windows problem if one works as expected, although I seem to recall running into something similar to this before withmix. Since Elixir supports Windows, I think this should probably work or be documented why. It would be great to understand why it doesn’t work. I haven’t read through theelixirandmixscripts in detail on Windows.