elixir -e "" fails on windows

Created on 16 Nov 2020  路  3Comments  路  Source: elixir-lang/elixir

Environment

  • Elixir & Erlang/OTP versions (elixir --version): 1.11.2, otp 23.1.2
  • Operating system: windows 10

Current behavior

While working on https://github.com/elixir-lsp/vscode-elixir-ls/pull/154 I discovered a small issue in command line parameter handling

elixir -e ""
** (TokenMissingError) nofile:1:3 missing terminator: "

It works as expected on macOS and linux.

I realise that it's not a very useful feature. In vscode-elixir-ls it is used to test if elixir command is in PATH and behaves properly. In this particular case it could be easily replaced with e.g. elixir --version but looking into elixir.bat i can see other params are being handled in the same way.

Expected behavior

Proper handling of empty strings

Bug Windows

Most helpful comment

%~1 causes %1 to expand thus removing any surrounding quotes
https://github.com/elixir-lang/elixir/blob/36d12b4bd4d26533c216e935903206cc3502200f/bin/elixir.bat#L101

Changing

set "VAR=%~1" 
rem to this
set "VAR=%1"

Makes the error go away, I don't know how viable this is since I don't use Elixir, just wanted to point that.

All 3 comments

Are we sure this isn't just a particularity of the windows shell? Elixir receives the command line argument as they are passed from the OS. If the OS passes down "" as " there isn't much we can do.

@ericmj my windows cmd knowledge is rusty but params are being parsed by elixir.bat https://github.com/elixir-lang/elixir/blob/36d12b4bd4d26533c216e935903206cc3502200f/bin/elixir.bat#L100
BTW this bug is reproducible both in cmd and powershell terminal

%~1 causes %1 to expand thus removing any surrounding quotes
https://github.com/elixir-lang/elixir/blob/36d12b4bd4d26533c216e935903206cc3502200f/bin/elixir.bat#L101

Changing

set "VAR=%~1" 
rem to this
set "VAR=%1"

Makes the error go away, I don't know how viable this is since I don't use Elixir, just wanted to point that.

Was this page helpful?
0 / 5 - 0 ratings