bitwalker / distillery

Simplify deployments in Elixir with OTP releases!
MIT License
2.96k stars 397 forks source link

Arguments starting by `--` except the first are ignored when using release_remote_ctl with `--argv -- "$@"` #625

Closed rlefevre closed 5 years ago

rlefevre commented 5 years ago

Steps to reproduce

Add a mix task:

defmodule Mix.Tasks.Test do
  use Mix.Task

  def run(args) do
    IO.inspect(args)
  end
end

Create an associated command in rel/config.exs:

  # Custom commands
  set(
    commands: [
      test: "rel/commands/test.sh"
    ]

and add the rel/commands/test.sh script:

#!/usr/bin/env bash

release_remote_ctl rpc --mfa "Mix.Tasks.Test.run/1" --argv -- "$@"

Run the command with some --bar argument in second then first position:

$ ./bin/app test foo --bar
["foo"]

$ ./bin/app test --bar foo
["--bar", "foo"]

Description of issue

Using distillery 2.0.12 on Amazon Linux release 2 (Karoo) and release_remote_ctl rpc --mfa "Mix.Tasks.Test.run/1" --argv -- "$@", I was expecting the -- to allow any argument to have a prefixed --, but it seems that only the first argument can. Others arguments starting by -- are not passed to the function in the arguments list.

I'm not sure if this is expected or not, but it prevents to have several flags arguments. Note that the arguments are correctly received when using mix.

bitwalker commented 5 years ago

This is fixed in the latest version of artificery, you can get it via mix deps.update artificery. Let me know if you see any more weird behavior with argument parsing!